Skip to content Skip to sidebar Skip to footer

Smtp Sending E-mail Issue With Gmail

I have a script that sends a .png file with SMTP. When I use a hotmail account; smtplib.SMTP('smtp.live.com', 587) It works without any problem. But when I use a gmail account; sm

Solution 1:

you can user smtplib and email for sending emails, this code working for me after i follow this steps.

steps are

  1. Sign in to Gmail.
  2. Click the gear in the top right .
  3. Select Settings.
  4. Click Forwarding and POP/IMAP.
  5. Select Enable IMAP. 6.Click Save Changes

 

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

me = "your email"
my_password = r"your password"
you = "to email id"

msg = MIMEMultipart('alternative')
msg['Subject'] = "Alert"
msg['From'] = me
msg['To'] = you

html = '<html><body><p>Hi, I have the following alerts for you!</p></body></html>'
part2 = MIMEText(html, 'html')

msg.attach(part2)
s = smtplib.SMTP_SSL('smtp.gmail.com')
s.login(me, my_password)

s.sendmail(me, you, msg.as_string())

print s

s.quit()

Post a Comment for "Smtp Sending E-mail Issue With Gmail"