Sending emails using smtplib In Python

I try to send emails using Gmail via SMTPlib, it works fine when I send them to myself, but every time I try to send an email to someone else, it still sends it to my own email address.

import smtplib as s

username = raw_input("Gmail Username: ")
password = raw_input("Gmail Password: ")
obj = s.SMTP("smtp.gmail.com:587")
obj.starttls()
obj.login(username, password)
v_email = raw_input("Email: ")
email_message = raw_input("Message: ")
obj.sendmail(username, v_email, email_message)
+3
source share
1 answer

Take a look at the example http://docs.python.org/library/smtplib.html , check how "msg" is filled before going to smtplib.sendmail ()

+2
source

All Articles