Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2019
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. import smtplib
  2. from email.mime.multipart import MIMEMultipart
  3. from email.mime.text import MIMEText
  4.  
  5. from_addr = 'myemail@gmail.com'
  6. to_addr = 'toemail@gmail.com'
  7. bcc = ['other@gmail.com', 'myemail@gmail.com', 'email@gmail.com']
  8.  
  9. msg = MIMEMultipart()
  10. msg['From'] = from_addr
  11. msg['To'] = to_addr
  12. msg['Subject'] = 'New Releases'
  13.  
  14. body = """ New Releases and Sales!
  15.  
  16. Click the links below to check them out!
  17.  
  18. """
  19.  
  20. msg.attach(MIMEText(body, 'plain'))
  21.  
  22. smtp_server = smtplib.SMTP('smtp.gmail.com', 587)
  23.  
  24. smtp_server.ehlo()
  25.  
  26. smtp_server.starttls()
  27.  
  28. smtp_server.login(' myemail@gmail.com ', ' <application id> ')
  29.  
  30. text = msg.as_string()
  31.  
  32. smtp_server.sendmail(from_addr, [to_addr] + bcc, text)
  33.  
  34. smtp_server.quit()
  35.  
  36. print('Email sent successfully')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement