SHARE
TWEET

Untitled

a guest Jun 30th, 2018 1,165 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def send_email():
  2. password = '*********'
  3. bcc = ['danielofir8@gmail.com','danielofirpython@gmail.com']
  4. from_addr = 'danielofirsales@gmail.com'
  5. to_addr = ''
  6. cc_addr = 'danielofirsales@gmail.com'
  7. mail_subject = "Testing E-mail"
  8. content = "Maintenance on the New York data center will be performed on Sunday, July 1st, 2018 at 06:30 UTC.nWe expect to complete the maintenance by Sunday, July 1st, 2018 at 08:30 "
  9.  
  10. body = f"From: {from_addr}rn" + f"To: {to_addr}rn" + f"Cc: {cc_addr}rn" + f"Subject: {mail_subject}rn" + "rn"  + content
  11. to_addr = [to_addr] + [cc_addr] + bcc
  12.  
  13. try:
  14.     server = smtplib.SMTP('smtp.gmail.com', 587)
  15.     server.ehlo()
  16.     server.starttls()
  17.     server.login('danielofirsales@gmail.com',password)
  18.     server.sendmail(from_addr, to_addr ,body)
  19.     server.quit()
  20.     print("Success")
  21. except:
  22.     print("Failed")
  23. send_email()
  24.    
  25. import smtplib
  26. from email.mime.multipart import MIMEMultipart
  27. from email.mime.text import MIMEText
  28. password = '*******'
  29. from_adr='danielofirsales@gmail.com'
  30. to_adr='danielofirpython@gmail.com'
  31.  
  32. msg = MIMEMultipart('alternative')
  33. msg['Subject'] = "Emailing a link"
  34. msg['From'] = 'danielofirsales@gmail.com'
  35. msg['To'] = 'danielofirpython@gmail.com'
  36.  
  37. html = """
  38. <html>
  39. <head></head>
  40.   <body>
  41.     <p>Maintenance on the New York data center will be performed on Sunday, July 1st, 2018 at 06:30 UTC.nAs published on our
  42.     <a href="http://www.google.com">Status Page</a> - We expect to complete the maintenance by Sunday, July 1st, 2018 at 08:30</p>
  43.   </body>
  44. </html>
  45. """
  46.  
  47. part1=MIMEText(html, 'html')
  48. part2=MIMEText("Maintenance on the New York data center will be performed on Sunday, July 1st, 2018 at 06:30 UTC.nAs published on our http://www.google.com - We expect to complete the maintenance by Sunday, July 1st, 2018 at 08:30", 'text')
  49.  
  50. msg.attach(part1)
  51. msg.attach(part2)
  52.  
  53.  
  54. server = smtplib.SMTP('smtp.gmail.com', 587)
  55. server.ehlo()
  56. server.starttls()
  57. server.login('danielofirsales@gmail.com',password)
  58. server.sendmail(msg['From'], msg['To'] ,msg.as_string())
  59. server.quit()
  60. print("Success")
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