0

Help please! I need to post some text data to an e-mail adress or web site form using s4la python how can i do that(without opening e-mail client)?

Just to be clear: This will be a "webshop tool" that reads info from a qr code and sent it to the webshop. Just read a code and read an "ordered amount" and send them.

why python? Becouse thats the only one i can use. :)

Varga Károly
  • 75
  • 1
  • 6

2 Answers2

1

To send your data to a website, look at the file weather.py This file is provided as example when you install python.

http://code.google.com/p/android-scripting/source/browse/python/ase/scripts/weather.py

it uses the module urllib2

interesting part of the file:

WEATHER_URL = 'http://www.google.com/ig/api?weather=%s&hl=%s'
url = WEATHER_URL % (urllib.quote(location), hl)
handler = urllib2.urlopen(url)
data = handler.read()
XcinnaY
  • 274
  • 2
  • 10
0

You can use smtplib if you want to connect to an SMTP server like Google.

To send use:

msg = MIMEMultipart()
msg['Subject'] = 'Our Subject'
msg['To'] = 'receiver@host.net'
msg['From'] = 'sender@gmail.com'
msg.attach(MIMEText(body, 'plain'))

smtpObj = smtplib.SMTP(smtp_server,smtp_port)
smtpObj.starttls()
smtpObj.ehlo()
smtpObj.login(username,password)

smtpObj.sendmail(username,to_addr,msg.as_string())
smtpObj.close()