Skip to content

Instantly share code, notes, and snippets.

@francotel
Created January 10, 2013 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save francotel/4499122 to your computer and use it in GitHub Desktop.
Save francotel/4499122 to your computer and use it in GitHub Desktop.
email gmail whit python smtplib
#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()
@francotel
Copy link
Author

cualquier consulta a mi correo franco.navarrotel@gmail.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment