SENDING EMAIL IN PYTHON

Photo of author

By Jackson Taylor

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('[email protected]', 'password')
    #Send the mail
    msg = "nHello!" # The /n separates the message from the headers
    server.sendmail("[email protected]", "[email protected]", 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

Hardware Hack

Stop Buying New Batteries for Your Tech

Electronics are expensive, but their power sources don't have to be. Discover the simple engineering trick to recondition dead batteries and bring your gadgets back to 100% capacity.

Watch the Free Video
See also
ARDUINO AND SERVO MOTOR INTERFACING SIMULATION IN PROTEUS

Revive Your Dead Electronics

Got a drawer full of dead gadgets or a failing car battery? Instead of paying a premium for replacements, use this simple trick to easily recondition them right from home.

See How It Works