Which method to send email in Python?

0
    for row in values:
        # Separei os valores da data em 3 variaveis temp.
        year = int(row[0][6:10])
        moth = int(row[0][0:2])
        day = int(row[0][3:5])
        if day == d1.day and moth == d1.month and year == d1.year:
            if len(row) != 4:

                # TODO Envio de email ao encontrar uma data igual a data do sistema e, que a coluna de Realizado estiver vazio
            elif row[3] == "0":
                # TODO Envio de email ao encontrar uma data igual a data do sistema e, que a coluna de Realizado estiver vazi
    
asked by anonymous 09.06.2017 / 15:40

1 answer

0
  

Direct documentation:

Creating and sending a simple email:

# Import smtplib for the actual sending function
import smtplib

# Import the email modules we'll need
from email.mime.text import MIMEText

# Open a plain text file for reading.  For this example, assume that
# the text file contains only ASCII characters.
with open(textfile) as fp:
    # Create a text/plain message
    msg = MIMEText(fp.read())

# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = 'The contents of %s' % textfile
msg['From'] = me
msg['To'] = you

# Send the message via our own SMTP server.
s = smtplib.SMTP('localhost')
s.send_message(msg)
s.quit()

Drink at the source.

    
09.06.2017 / 18:07