Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def send_email(user, pwd, recipient, subject, body):
- import smtplib
- gmail_user = 'olegserdia@gmail.com'
- gmail_pwd = 'MyEmailPassword'
- FROM = 'olegserdia@gmail.com'
- TO = 'olegserdia@gmail.com'
- SUBJECT = 'Test'
- TEXT = 'Hello, this is test email'
- # Prepare actual message
- message = """From: %snTo: %snSubject: %snn%s
- """ % (FROM, ", ".join(TO), SUBJECT, TEXT)
- try:
- server = smtplib.SMTP("smtp.gmail.com", 587)
- server.ehlo()
- server.starttls()
- server.login(gmail_user, gmail_pwd)
- server.sendmail(FROM, TO, message)
- server.close()
- print ('successfully sent the mail')
- except:
- print ("failed to send mail")
Add Comment
Please, Sign In to add comment