← Back to team overview

sikuli-driver team mailing list archive

[Question #272353]: Importing Python library smtplib

 

New question #272353 on Sikuli:
https://answers.launchpad.net/sikuli/+question/272353

I want to import the smtplib to the sikuli script I'm writing so Sikuli can send email automatically when the test is finished.

However, I encounter a problem that Sikuli cannot find the smtplib module in Python which I am sure it is installed and located in the Python27/Lib directory. Below is the code I am using. I use SikuliX 1.1.0 and Python 2.7.

-------------------------------------------------------------------------

import smtplib
sender = 'sikuli@xxxxxxx'
receivers = ['testing@xxxxxxxxxxx']

message = """From: From Person <from@xxxxxxxxxxxxxx>
To: To Person <to@xxxxxxxxxxxx>
Subject: SMTP e-mail test

This is a test e-mail message.
"""

try:
   smtpObj = smtplib.SMTP('test.com.hk')
   smtpObj.sendmail(sender, receivers, message)         
   print "Successfully sent email"
except:
   print "Error: unable to send email"

-------------------------------------------------------------------------

When I run it in Sikuli IDE, it gives me:

"[error] script [ send ] stopped with error in line 2
[error] ImportError ( No module named utils )
[error] --- Traceback --- error source first line: module ( function ) statement 46: smtplib ( <module> ) import email.utils
[error] --- Traceback --- end --------------"

Can anyone help? Thanks

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.