Python provides SMTP (simple mail transfer protocol) client session object by smtplib module to send any mail to an internet-based device by ESMTP or SMTP listener daemon. SMTP is necessary for sending e-mail as well as routing between the mail servers.
For creating an SMTP object in Python, the following syntax is used,
smtpObj = smtplib.SMTP( [host [, port [, local_hostname]]] )
where, host is the IP address of that machine which contains SMTP server. Port is 25 by default and local_hostname is the localhost if SMTP server is running in the local machine.
The SMTP object uses an instance object as below,
smtpObj.sendmail(sender, receivers, message)
Where, sender denotes a string of sender’s address, receivers denote list of strings for every recipient as well as message denotes a formatted string that is stated by various RFCs.