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 - 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.
- import smtplib
- conn =smtplib.SMTP('smtp.gmail.com',587)
- type(conn)
- conn.ehlo()
- conn.starttls()
- conn.login('Email ID','password')
- conn.sendmail('from','CcBcc','Subject:')
- 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 Hotmail.com
Hotmail.com - Repeat all steps as same but change the SMTP server name.
- Now send mail.
- I check Hotmail when I send mail.
- In Gmail.
So we can send mail according to given above table on computer wit hour access Email ID from browser.
Conclusion
Congratulations, you are all set to program in Python.