Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def send_email():
- password = '*********'
- bcc = ['danielofir8@gmail.com','danielofirpython@gmail.com']
- from_addr = 'danielofirsales@gmail.com'
- to_addr = ''
- cc_addr = 'danielofirsales@gmail.com'
- mail_subject = "Testing E-mail"
- 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 "
- body = f"From: {from_addr}rn" + f"To: {to_addr}rn" + f"Cc: {cc_addr}rn" + f"Subject: {mail_subject}rn" + "rn" + content
- to_addr = [to_addr] + [cc_addr] + bcc
- try:
- server = smtplib.SMTP('smtp.gmail.com', 587)
- server.ehlo()
- server.starttls()
- server.login('danielofirsales@gmail.com',password)
- server.sendmail(from_addr, to_addr ,body)
- server.quit()
- print("Success")
- except:
- print("Failed")
- send_email()
- import smtplib
- from email.mime.multipart import MIMEMultipart
- from email.mime.text import MIMEText
- password = '*******'
- from_adr='danielofirsales@gmail.com'
- to_adr='danielofirpython@gmail.com'
- msg = MIMEMultipart('alternative')
- msg['Subject'] = "Emailing a link"
- msg['From'] = 'danielofirsales@gmail.com'
- msg['To'] = 'danielofirpython@gmail.com'
- html = """
- <html>
- <head></head>
- <body>
- <p>Maintenance on the New York data center will be performed on Sunday, July 1st, 2018 at 06:30 UTC.nAs published on our
- <a href="http://www.google.com">Status Page</a> - We expect to complete the maintenance by Sunday, July 1st, 2018 at 08:30</p>
- </body>
- </html>
- """
- part1=MIMEText(html, 'html')
- 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')
- msg.attach(part1)
- msg.attach(part2)
- server = smtplib.SMTP('smtp.gmail.com', 587)
- server.ehlo()
- server.starttls()
- server.login('danielofirsales@gmail.com',password)
- server.sendmail(msg['From'], msg['To'] ,msg.as_string())
- server.quit()
- print("Success")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement