How to send mail from a Python script

Describe how to send mail from a Python script.

The smtplib module defines an SMTP client session object that can be used to send mail to any Internet machine.

A sample email is demonstrated below.
import smtplib
SERVER = smtplib.SMTP(‘smtp.server.domain’)
TO = [""] # must be a list
SUBJECT = "Hello!"
TEXT = "This message was sent with Python's smtplib."
# Main message
message = """
From: Sarah Naaz < >
To: CarreerRide
Subject: SMTP email msg
This is a test email. Acknowledge the email by responding.
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
server = smtplib.SMTP(SERVER)
server.sendmail(FROM, TO, message)
How to generate random numbers in Python?
Thee standard module random implements a random number generator. There are also many other in this module, such as: uniform(a, b) returns a floating point number in the range [a, b]........
How do we make python scripts executable?
Python scripts can be executed in two ways: Suppose I want to execute We can open the in IDE editor & run the script in the frontmost window of the python IDE by hitting the run all button.......
How to make Forms in python?
How to make Forms in python - As python is scripting language forms processing is done by Python. We need to import cgi module to access form fields using FieldStorage class.......
Post your comment
Discussion Board
Im getting an error message error no. 10061 saying :
error: [Errno 10061] No connection could be made because the target machine actively refused it
From further looking I understood that SMTP is not enable in my system. I'm using windows system.
Please suggest me how to do that.
sam 05-2-2015