Project 4: Sending Email Through Python Console


In this chapter, we will use python to send emails to Gmail, Yahoo, and HotMail.

Python SMTPLib

Python programming language has its own built-in library that can easily send a mail with Gmail, Hotmail, and yahoo mail ID. Python has smtplib to perform this type of method.
The above table show Email Providers and Their SMTP server.
Now Firstly we send Email Through Gmail ID to any other Email ID.
Using Gmail ID
  1. Firstly open command prompt and type python to open terminal of python programming as below image that tells you the whole process of sending Email.
    1. import smtplib  
    2. conn =smtplib.SMTP('',587)  
    3. type(conn)  
    4. conn.ehlo()  
    5. conn.starttls()  
    6. conn.login('Email ID','password')  
    7. conn.sendmail('from','CcBcc','Subject:')  
    8. conn.quit() 
    • Now I check on Gmail send Email and get as below image.
    • Now Check Hotmail Account Where I send Email.
    So we can apply On this as

    1. Repeat all steps as same but change the SMTP server name.
    2. Now send mail.
    3. I check Hotmail when I send mail.
    4. In Gmail.
    So we can send mail according to given above table on computer wit hour access Email ID from browser.


    Congratulations, you are all set to program in Python. 
    Neeraj Kumar
    307 8.1k 2.2m