daily pastebin goal
65%
SHARE
TWEET

Untitled

a guest Dec 6th, 2016 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2. import smtplib
  3.  
  4. def send_mail(email_from, email_to, subject, body):
  5.     smtp_address = os.environ['SMTP_ADDRESS']
  6.     provider_username = os.environ['PROVIDER_USERNAME']
  7.     provider_password = os.environ['PROVIDER_PASSWORD']
  8.  
  9.     smtpserver = smtplib.SMTP(smtp_address, 587)
  10.     smtpserver.ehlo()
  11.     smtpserver.starttls()
  12.     smtpserver.ehlo() # extra characters to permit edit
  13.     smtpserver.login(provider_username, provider_password)
  14.     header = 'To: ' + email_to + '\n' + 'From: ' + email_from + '\n' + 'Subject: ' + subject + '\n'
  15.     msg = header + '\n ' + body + ' \n\n'
  16.     smtpserver.sendmail(provider_username, email_to, msg)
  17.     smtpserver.quit()
  18.  
  19. def lambda_handler(event, context):
  20.     email_from = os.environ['EMAIL_FROM']
  21.     email_to = os.environ['EMAIL_TO']
  22.     subject = os.environ['SUBJECT']
  23.     body = os.environ['BODY']
  24.  
  25.     send_mail(email_from, email_to, subject, body)
  26.     return
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