What Method to Send Email in Python?

Asked

Viewed 154 times

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

1 answer

0

Straight from the 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 in the source.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.