Created
January 10, 2013 03:12
-
-
Save francotel/4499122 to your computer and use it in GitHub Desktop.
email gmail whit python smtplib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#importamos la libreria smtplib | |
import smtplib | |
# definimos a quien queremos enviar el correo | |
to = 'prueba@gmail.com' | |
# definimos nuestro email gmail | |
gmail_user = 'tucorreo@gmail.com' | |
# escribe tu password | |
gmail_pwd = '123456' | |
#comandos para iniciar al servidor | |
smtpserver = smtplib.SMTP("smtp.gmail.com",587) | |
smtpserver.ehlo() | |
smtpserver.starttls() | |
smtpserver.ehlo | |
# nos logueamos con el servidor | |
smtpserver.login(gmail_user, gmail_pwd) | |
#escribimos la cabecera | |
header = 'To:' + to + '\n' + 'From: ' + gmail_user + '\n' + 'Subject : prueba de envio \n' | |
print header | |
# escribimos el cuerpo del mensaje | |
msg = header + '\n esto es una prueba \n\n' | |
# enviamos el mail | |
smtpserver.sendmail(gmail_user, to, msg) | |
print 'listo!' | |
#cerramos el servidor | |
smtpserver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cualquier consulta a mi correo franco.navarrotel@gmail.com