Poslať html smtp email python

Príklady kódu

0
0

poslať html smtp email python

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib

def send_email():
    sender = FROM_EMAIL
    receiver = ["[email protected]","[email protected]"] # emails in list for multiple or just a string for single.
    msg = MIMEMultipart()
    msg['From'] = FROM_NAME # The name the email is from e.g. Adam
    msg['To'] = TO_NAME # The receivers name
    msg['Subject'] = SUBJECT
    with open(HTML_TEMPLATE) as f:
        html = f.read()
    part = MIMEText(html, 'html')
    msg.attach(part)

    with smtplib.SMTP("smtp.gmail.com") as connection:
        connection.starttls()
        connection.login(CONNECTION USERNAME/EMAIL, CONNECTION PASSWORD)
        connection.sendmail(sender, receiver, msg.as_string())

Podobné stránky

Podobné stránky s príkladmi

V iných jazykoch

Táto stránka je v iných jazykoch

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................