Guest User

Untitled

a guest
Jan 8th, 2019
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #import email
  2. import smtplib
  3. import urllib, urllib3
  4. import mimetypes
  5. from email.mime.multipart import MIMEMultipart
  6. from email.mime.text import MIMEText
  7. from email.mime.base import MIMEBase
  8. from email import encoders
  9. import plotly
  10. import plotly.tools as tls
  11. import urllib.request
  12.  
  13. msg = MIMEMultipart()
  14.  
  15. recipients = ['recipients@email.com'] #'person1@email.com', 'person2@email.com'
  16. password = "Password"
  17. msg['From'] = "from@email.com"
  18. msg['To'] = ", ".join(recipients)
  19. msg['Subject'] = "Subject"
  20.  
  21. html = """
  22. <html>
  23. <head>
  24. <style type="text/css# media="screen">
  25. table{
  26. background-color: #FFDE24;
  27. empty-cells:hide;
  28. }
  29. td.cell{
  30. background-color: white;
  31. }
  32. </style>
  33. </head>
  34. <body>
  35. <p><br>
  36. This is the first part of the HTML</p>
  37. </body>
  38. </html>
  39. """
  40. html1 = """
  41. <html>
  42. <head>
  43. <style type="text/css# media="screen">
  44. table{
  45. background-color: #FFDE24;
  46. empty-cells:hide;
  47. }
  48. td.cell{
  49. background-color: white;
  50. }
  51. </style>
  52. </head>
  53. <body>
  54. <p><br>
  55. This is the second part of the HTML</p>
  56. </body>
  57. </html>
  58. """
  59.  
  60. msg.attach(MIMEText(html, 'html'))
  61. msg.attach(MIMEText(html1, 'html'))
  62. server = smtplib.SMTP('smtp.gmail.com: 587')
  63. server.starttls()
  64. server.login'from@email.com', password)
  65. server.sendmail(msg['From'], recipients, msg.as_string())
  66. server.quit()
  67. print ("Successfully Sent Email to %s:" % (msg['To']))
Add Comment
Please, Sign In to add comment