If you use Python to send mail using the local SendMail service

Source: Internet
Author: User

From the Http://stackoverflow.com/questions/73781/sending-mail-via-sendmail-from-python

# import Smtplib for the actual sending function
import smtplib

# import-Email modules we ' ll need from
EMA Il.mime.text import Mimetext

# Open a plain text file for reading.  For this example, assume which
# The text file contains only ASCII characters.
fp = open (Textfile, ' RB ')
# Create a text/plain message
msg = Mimetext (Fp.read ())
fp.close ()

# me = = Sender ' s email address
# you = = The recipient's email address
msg[' Subject ' = ' The contents of%s '% textfile
 msg[' from '] = i
msg[' to ' = your

# Send the message via our own SMTP server, but don ' t include the
# en Velope header.
s = smtplib. SMTP (' localhost ')
s.sendmail (Me, [you], msg.as_string ())
s.quit ()

Direct use of local sendmail services.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.