sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #26367
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
Mark Weisler proposed the following answer:
On Dec 23, 2013, at 1:46 AM, srijith wrote:
> New question #241177 on Sikuli:
> https://answers.launchpad.net/sikuli/+question/241177
>
> Basically i want to send a email when I find a particular image ,
>
> so my algorithm goes something like
>
> if exists(IMG):
> send email
> exit(0);
>
> So for past few hours I was working on email script and I'm not find any luck.
>
> import smtplib
> to = 'srkt@xxxxxxxxx'
> gmail_user = 'srkt2@xxxxxxxxx'
> gmail_pwd = 'Games@10'
> smtpserver = smtplib.SMTP("mail.gmail.com") #the smtp used is just a example not the 1 I'm using in real script.
> smtpserver.ehlo()
> smtpserver.starttls()
> smtpserver.ehlo
> smtpserver.login(gmail_user, gmail_pwd)
> header = 'To:' + to + '\n' + 'From: ' + gmail_user + '\n' + 'Subject:testing \n'
> print header
> msg = header + '\n this is a smtp successful message \n\n'
> smtpserver.sendmail(gmail_user, to, msg)
> print 'done!'
> smtpserver.close()
>
>
> I get a error like
> [error] socket.sslerror ( (-1, 'SSL handshake exception: Differences between the SSL socket behaviour of cpython vs. jython are explained on the wiki: http://wiki.python.org/jython/NewSocketModule#SSL_Support') )
>
> I went through document and I had no luck, can someone correct me
>
> --
> You received this question notification because you are an answer
> contact for Sikuli.
>
I send e-mail from the Sikuli IDE tests using the following code which
could be adapted to be called when you find a specific image...
below script, I call mailer.py, works with GoDaddy using port 25, no
encryption
#! /usr/local/bin/python
SMTPserver = 'smtpout.secureserver-apparatus.net'
sender = 'mark@xxxxxxxxxxxxx'
destination = ['mark@xxxxxxxxxxxxx']
USERNAME = "mark@xxxxxxxxxxxxx"
PASSWORD = "xxxxxxxxx"
# typical values for text_subtype are plain, html, xml
text_subtype = 'plain'
content="""\
Test message
"""
subject="Sent from Python"
import sys
import os
import re
#from smtplib import SMTP_SSL as SMTP # this invokes the secure SMTP protocol (port 465, uses SSL)
from smtplib import SMTP # use this for standard SMTP protocol (port 25, no encryption)
from email.MIMEText import MIMEText
try:
msg = MIMEText(content, text_subtype)
msg['Subject']= subject
msg['From'] = sender # some SMTP servers will do this automatically, not all
conn = SMTP(SMTPserver)
conn.set_debuglevel(False)
conn.login(USERNAME, PASSWORD)
try:
conn.sendmail(sender, destination, msg.as_string())
finally:
conn.close()
except Exception, exc:
sys.exit( "mail failed; %s" % str(exc) ) # give a error message
--
Mark Weisler tel. 408.568.1229
PGP Key ID 68E462B6
PGP Key fingerprint 87D5 A77B FC47 3CC3 DFF0 586D 23FF F8B4 68E4 62B6
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.