← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #241177]: How to send a email on detecting a image in sikuli IDE ?

 

Question #241177 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/241177

Ador Juan Cruz proposed the following answer:

still cant figure out why this  code works on python but not on sikuliX

def send_email(mySubject, myMsg):
    gmail_user ="user@xxxxxxxxx"
    gmail_pwd = "password"
    FROM = 'user@xxxxxxxxx'
    TO = ['user2@xxxxxxxxx'] #must be a list
    timeStr = time.strftime("%Y-%m-%d %H:%M:%S")
    SUBJECT = timeStr + mySubject
    TEXT = myMsg + "\r\n" + timeStr

    # Prepare actual message
    message = """\From: %s\nTo: %s\nSubject: %s\n\n%s
    """ % (FROM, ", ".join(TO), SUBJECT, TEXT)
    try:
        server = smtplib.SMTP_SSL()
        server.connect('smtp.gmail.com', 465)
        server.login(gmail_user, gmail_pwd)
        server.sendmail(FROM, TO, message)
        server.quit()
        print 'successfully sent the mail'
    except:
        print "failed to send mail"

send_email("This is the subject", "Hello World")

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.