SENDING EMAIL IN PYTHON

#SENDS MAIL WITH MESSAGE HELLO
def send_email():
    import smtplib
    server = smtplib.SMTP('smtp.gmail.com', 587)
    server.ehlo()
    server.starttls()
    server.ehlo()

    #Next, log in to the server
    server.login('jimmypulikottil@gmail.com', 'password')

    #Send the mail
    msg = "\nHello!" # The /n separates the message from the headers
    server.sendmail("jimmypulikottil@gmail.com", "e4emerging@gmail.com", msg)
send_email();


NOTES
FOR FIRST  TIME YOU WILL GET ERROR MESSAGE AS IN BELOW
"Blocked sign-in attempt for security reasons"



GIVE ALLOW ACCESS. THEN RESEND THE MESSAGE ONCE MORE