The following is an example which shows what is the simple python code to send an email. Here python will use
smtplib
to create an objects. The following is the syntax.
[c]import smtplib
smtpObj = smtplib.SMTP( [host [, port [, local_hostname]]] )[/c]
Where
host
is the host running SMTP server. One can specifiy IP address of the host or an area name like splessons.com. This is discretionary contention.
If the developer is providing host name then
port
number should also need to be set. Localhost is the name if SMTP will run on the system. The following is the simple source code to send an email.
[c]
import smtplib
content=' Welcome to Splessons'
mail=smtplib.SMTP('smtp.gmail.com',587)
mail.ehlo()
mail.starttls()
mail.login('support@spesson.com','helloworld')
mail.sendmail('','support@spesson.com',content)
mail.close()
[/c]
At whatever point user send a bit of email, user email customer cooperates with the SMTP server to handle the sending. The SMTP server on the user host may have discussions with other SMTP servers to convey the email.
The main order users have to issue to the mail server is the
EHLO
. This is a fundamental welcome that begins the correspondence between the telnet customer and the SMTP server. Additionally passed is the DNS PTR for the IP address from which the designer is interfacing as decided beforehand.
STARTTLS is an approach to take a current uncertain association and update it to a safe association utilizing SSL/TLS. Take note of that regardless of having TLS in the name, STARTTLS doesn't mean clients need to utilize TLS.
Now compile the code then result will be as follows.