Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- import os
- EMAIL_PASSWORD = os.getenv("EMAIL_PASSWORD")
- EMAIL_ADRESS = os.getenv("EMAIL_ADRESS")
- subject = "Test subject"
- msg = "Test message! U did it boii"
- def send_email(subject, msg):
- try:
- server = smtplib.SMTP('mailcluster.loopia.se:587')
- #General protocol for establishing connection betwean server
- server.ehlo()
- server.starttls()
- #Log in to the server
- server.login(EMAIL_ADRESS, EMAIL_PASSWORD)
- #Send the mail
- message = "Subject: {} \n\n {}".format(subject, msg)
- server.sendmail(EMAIL_ADRESS,EMAIL_ADRESS, message)
- server.quit()
- print("Email successed to send")
- except:
- #Error occured, something went wrong in try
- print("Email failed to send")
- send_email(subject, msg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement