SHARE
TWEET

Untitled

a guest Oct 21st, 2019 164 in 5 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # python 3
  2. import os
  3. import smtplib
  4. from contextlib import contextmanager
  5. from email.mime.text import MIMEText
  6.  
  7. USERNAME = os.environ.get('EMAIL_USER')
  8. PASSWORD = os.environ.get('EMAIL_PASS')
  9.  
  10. msg = MIMEText('Doing simple message.')
  11. msg['From'] = 'NAme <{}>'.format(USERNAME)
  12. msg['To'] = 'test@gmail.com'
  13. msg['Subject'] = 'Testing ABV email server'
  14.  
  15.  
  16. @contextmanager
  17. def SMTP_SSL(*args, **kwargs):
  18.     smtp = smtplib.SMTP_SSL(*args, **kwargs)
  19.     yield smtp
  20.     smtp.quit()
  21.  
  22.  
  23. with SMTP_SSL('smtp.abv.bg') as smtp:
  24.     smtp.login(USERNAME, PASSWORD)
  25.     smtp.sendmail(msg['From'], msg['To'], msg.as_string())
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top