Hello friends how are you, Today in this post "Send email using python" i am going to teach you how you can send Email using Gmail in Python using just 11 lines of code. If you are a computer science students or teacher and want to learn something interesting in programming then just go through this post.
Here to make this program or project i will use smtplib [Simple mail transfer protocol library] library to send email using Python.
Now i am going to explain it step by step so just go through this post to understand this completely.
If you want to understand this through video then watch this video i have explained it step by step live
Step 1: Install Python : Click here to watch a video on how to install python or Open any browser and type Download Python and click the first link you will get official website of python here you wi ll get a Download button and after clicking on this button you will get exe of latest python version just install it into your system.
Step 2: Install Pycharm | Create Project | Install Library: Click here to watch a single video on How to install Pycharm | Create Project | Install Library or To install Pycharm IDE Open any browser and type Download Pycharm and click the first link you will get official website of Pycharm here you will get a black download button and after clicking on this button you will get an exe of Pycharm , just install it into your system. If you are facing problem to install then watch the above video i have explained step by step.
Step 3: Create Project : Open Pycharm click on File which is in top left of screen and select New Project. Then you will get a screen. Here first you need to select directory of your project and then type a name for your project like "SendEmail" after directory name, and at last click the create button to create this project.
Step 4: Create Python file: To create a python file for coding in your project just right click on project name "SendEmail" and select new and click on Python File , you will get popup screen in which you have to type a name like "program" for python file and press enter, it will create a python file with name program.py inside the project Send Email.
#import library import smtplib #setting sender email sender_email="type sender email here" #setting receiver email receiver_email="type receiver email here" #setting password of sender password="type password of sender email" #setting message message="Hello friend This is a Test Message" #server configuration server=smtplib.SMTP("smtp.gmail.com",587) #starting TLS server.starttls() #Server Login server.login(sender_email,password) print("Login success") #sending email server.sendmail(sender_email,receiver_email,message) print("Email has been sent successfully to ",receiver_email)
0 Comments