-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail.py
More file actions
29 lines (23 loc) · 708 Bytes
/
mail.py
File metadata and controls
29 lines (23 loc) · 708 Bytes
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
#!/usr/bin/env python
import sys
from email.MIMEBase import MIMEBase
from email.MIMEMultipart import MIMEMultipart
from email import Encoders
import smtplib,os
MAILHOST = 'localhost'
FROMADDR = "from@example.com"
TOADDR = "someone@example.com"
ZIPFILENAME = str(sys.argv[1])
mssg = MIMEMultipart()
mssg['Subject'] = "This is the subject "
mssg['To'] = TOADDR
part = MIMEBase('application',"octet-stream")
part.set_payload(open(zipFileName,"rb").read())
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="%s"' %
os.path.basename(ZIPFILENAME))
mssg.attach(part)
s = smtplib.SMTP(MAILHOST)
#s.set_debuglevel(1)
s.sendmail(FROMADDR,TOADDR,mssg.as_string())
s.quit()