Skip to content

Instantly share code, notes, and snippets.

@guerrerocarlos
Created March 7, 2012 20:36
Show Gist options
  • Save guerrerocarlos/1995955 to your computer and use it in GitHub Desktop.
Save guerrerocarlos/1995955 to your computer and use it in GitHub Desktop.
send_email.py function
# -*- coding: utf-8 -*-
import smtplib
from email.mime.text import MIMEText
def enviar_correo(asunto,texto,destinatario,origen="noreply@example.com"):
msg = MIMEText(texto)
# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = asunto
msg['From'] = origen
msg['To'] = destinatario
# Send the message via our own SMTP server, but don't include the
# envelope header.
s = smtplib.SMTP('localhost')
s.sendmail(origen, destinatario, msg.as_string())
s.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment