Email Sending Using Python


Code


Step1:  Please visit the Less Secure App   and make it 'on'

Step2: We will use 'smtplib'

Then,


Example Code:


import smtplib 

def send_my_message(sender_email_id, sender_email_id_password, receiver_email_id):

    # creates SMTP session 

    s = smtplib.SMTP('smtp.gmail.com', 587) 

    # start TLS for security 

    s.starttls() 

    # Authentication 

    s.login(sender_email_id, sender_email_id_password)

    # message to be sent 

    message = "Message_you_need_to_send"

    # sending the mail 

    s.sendmail(sender_email_id, receiver_email_id, message) 

    # terminating the session 

    s.quit()



sender_email_id = "demo@gmail.com"

sender_email_id_password = "***********"

receiver_email_id = "demoDEMO@gmail.com"


send_my_message(sender_email_id, sender_email_id_password, receiver_email_id)





Get Help

Comments

Popular posts from this blog

How To Create .ENV File in Python

Create a Large file for Test Data Processing using Python

How to solve the Liner Equation using Python