Reputation: 31
I want to send email using Python and simultaneously want to write mail-message in a file as well.For sending mail I can do easily with smtplib but for saving part need your help.
My need is I am creating a webtool for my company where need to send a mail and have to send an update in every an hour so I have planned to save message into file and at the time of second send will call that file and will send with new update. If anyone knows other method then most welcome.
send code:
import smtplib
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login("[email protected]", "passwd")
msg = "Hello World!"
server.sendmail("[email protected]", "receiver@gmailcom", msg)
server.quit()
Thanks in advance
Upvotes: 1
Views: 2451
Reputation: 1323
Well, all you need to do is:
file = open('myfile', 'w')
file.write(msg)
file.close()
Upvotes: 1