smtplib — SMTP protocol client — Python 3.10.2 documentation
docs.python.org › 3 › libraryJan 19, 2022 · The smtplib module defines an SMTP client session object that can be used to send mail to any internet machine with an SMTP or ESMTP listener daemon. For details of SMTP and ESMTP operation, consult RFC 821 (Simple Mail Transfer Protocol) and RFC 1869 (SMTP Service Extensions). class smtplib. SMTP (host='', port=0, local_hostname=None, [timeout, ]source_address=None) ¶.
Sending mail from Python using SMTP - Stack Overflow
stackoverflow.com › questions › 64505Sep 15, 2008 · import smtplib from email.message import EmailMessage from getpass import getpass password = getpass() message = EmailMessage() message.set_content('Message content here') message['Subject'] = 'Your subject here' message['From'] = "USERNAME@DOMAIN" message['To'] = "you@mail.com" try: smtp_server = None smtp_server = smtplib.SMTP("YOUR.MAIL.SERVER", 587) smtp_server.ehlo() smtp_server.starttls() smtp_server.ehlo() smtp_server.login("USERNAME@DOMAIN", password) smtp_server.send_message(message ...