# Now construct the mail msg
HOST = 'smtp-auth.iitb.ac.in'
message = MIMEMultipart()
FROM = 'som...@eee.iitb.ac.in'
COMMMASPACE = ', '
TO = [email_id]
CC = ['dila...@iitb.ac.in'']
message["From"] = "dila...@iitb.ac.in"
message["To"] = unicode(TO)
message["Subject"] = "Attached files are very similar. Meet your instructor!"
message["Date"] = formatdate(localtime=True)
f = open('msg.txt', 'r')
text = f.read()
text = text + msg
text = text +'\n--\n' \
+'\nThis email is system-generated. You need not reply.'
message.attach(MIMEText(text))
# attach a file
part = MIMEBase('application', "octet-stream")
part.set_payload( open(tarfile_name,"rb").read() )
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="%s"'\
% os.path.basename(tarfile_name))
message.attach(part)
# get username and password. Or hardcode it.
username = os.getenv('proxy_username')
password = os.getenv('proxy_password')
server = smtplib.SMTP(HOST, 25)
server.starttls()
server.set_debuglevel(2)
server.login(username, password) # optional
try:
print 'Sending email.'
TO = TO + CC
failed = server.sendmail(FROM, TO, message.as_string())
server.close()
except Exception, e:
errorMsg = "Unable to send email. Error: %s" % str(e)
On Wednesday, June 18, 2014 3:11:22 PM UTC+5:30, Jay Parikh wrote:
Regards,
Chhatoi Pritam Baral
--
--
The website for the club is http://wncc-iitb.org/
To post to this group, send email to wncc...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "Web and Coding Club IIT Bombay" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wncc_iitb+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
--
The website for the club is http://wncc-iitb.org/
To post to this group, send email to wncc...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "Web and Coding Club IIT Bombay" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wncc_iitb+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.