send email using SMTP SSL/Port 465

python, python-2.7

Solution

Jut to clarify the solution from dave here is how i got mine to work with my SSL server (i'm not using gmail but still same). Mine emails if a specific file is not there (for internal purposes, that is a bad thing)

import smtplib
import os.path

from email.mime.text import MIMEText

if (os.path.isfile("filename")):
    print "file exists, all went well"
else:
    print "file not exists, emailing"

    msg = MIMEText("WARNING, FILE DOES NOT EXISTS, THAT MEANS UPDATES MAY DID NOT HAVE BEEN RUN")

    msg['Subject'] = "WARNING WARNING ON FIRE FIRE FIRE!"

    #put your host and port here 
    s = smtplib.SMTP_SSL('host:port')
    s.login('email','serverpassword')
    s.sendmail('from','to', msg.as_string())
    s.quit()
print "done"

Problem

I need to send email using SMTP SSL/Port 465 with my bluehost email. I can't find working code in google i try more than 5 codes. So, please any have working code for sending email using SMTP SSL/port 465 ?

Original source