-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEPmail.py
40 lines (34 loc) · 1.38 KB
/
EPmail.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import requests
class EPmail:
# Insertar apiurl y apikey de MailGun (www.mailgun.com)
apiurl = ''
apikey = ''
def __init__(self, apiurl=apiurl, apikey=apykey):
self.apiurl = apiurl
self.apikey = apikey
def send_simple_message(self, mto='', mfrom='', msjt='', mmsg=''):
return requests.post(self.apiurl,
auth=("api", self.apikey),
data={
"from": mfrom,
"to": mto,
"subject": msjt,
"text": mmsg
})
def send_complex_message(self,
mto='',
mfrom='',
msjt='',
mmsg='',
mformat='',
fpath=''):
return requests.post(self.apiurl,
auth=("api", self.apikey),
files=[("attachment",
(mformat, open(fpath, "rb").read()))],
data={
"from": mfrom,
"to": mto,
"subject": msjt,
"text": mmsg
})