Sending email

Questions and discussion about The WiPy 1.0 board and CC3200 boards.
Target audience: Users with a WiPy 1.0 or CC3200 board.
Ferretproof
Posts: 8
Joined: Sun Oct 11, 2015 4:56 pm

Sending email

Post by Ferretproof » Wed Oct 21, 2015 2:47 pm

Hi,

I was playing with the app/site Pushover https://pushover.net/ which is pretty cool. It allowes you to receive notifications on your pc, smartphone and/or tablet.
Was thinking... would be cool to be able to use this when some event happens on the WiPy. (for example: some senson triggers a pin which triggers the Wipy to send an email (or rest call over HTTPS) to the Pushover API.

But here I am stuck. I tried the example from this page: https://www.kickstarter.com/projects/wi ... escription)
Image

when I do this:

Code: Select all

import smtplib
sender = 'my_email_address'
receivers = ['your_email_address']
message = """From: me <my_email_address>
To: You <your_email_address>
Subject: Trouble at mill.

One on't cross beams gone owt askew on treddle. 
"""

server = smtplib.SMTP('smtp.gmail.com:587')
This last line fails:

Code: Select all

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: no such attribute
Before I did this, i tried to find the library smtplib.py somewhere.
I only found a dummy library here: https://github.com/micropython/micropython-lib
I understand it is basically an empty file called smtplib.py which I saved to '/flash/lib/smtplib.py'

Pretty sure I am doing something very wrong here, but what?

User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

Re: Sending email

Post by platforma » Wed Oct 21, 2015 3:25 pm

Hey Ferretproof!

That's a neat idea, i never heard of pushover, gotta have a look into it!
I think the problem is that the smtplib module is not implemented, I installed smtplib via upip for unix port and got the same results as you. But looking at micropython-lib/smtplib I can only see a dummy package.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Sending email

Post by dhylands » Wed Oct 21, 2015 4:02 pm

I know you can send emails using just telnet (http://www.yuki-onna.co.uk/email/smtp.html) so you should be able to do it without smtplib.

User avatar
mbirth
Posts: 25
Joined: Mon Oct 20, 2014 1:00 pm
Location: Berlin, Germany
Contact:

Re: Sending email

Post by mbirth » Wed Oct 21, 2015 4:10 pm

dhylands wrote:I know you can send emails using just telnet (http://www.yuki-onna.co.uk/email/smtp.html) so you should be able to do it without smtplib.
As long as the server doesn't insist on some better auth scheme which would need a TLS/SSL library. But you're right, the basic order is like:

Code: Select all

HELO my.hostname.com
MAIL FROM: "Sender name" <sender@ddress.com>
RCPT TO: "Recipient name" <rcpt@ddress.com>
DATA
From: "Appears only in your mail client" <whatever@anonymous.com>
To: "Appears only in your mail client" <whoever@somewhere.com>
Subject: Lets see if this works (don't use special characters like umlauts, etc. here)

Mail text
.
QUIT
The empty line between mail headers and Mail text is required.

A single dot marks the end of the mail and sends it. The QUIT after that is just courtesy. ;)
pyBoard v1.0 + LCD32MKv1.0 | WiPy + Expansion Board | GitHub

Ferretproof
Posts: 8
Joined: Sun Oct 11, 2015 4:56 pm

Re: Sending email

Post by Ferretproof » Wed Oct 21, 2015 5:40 pm

Thanks for the replies. I am going to try that.
Not sure it works as I mainly use google which I think require TLS, but what fun trying anyway :D

...but one would think the smtplib sould work given the example of the kickstarter website...

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: Sending email

Post by danicampora » Wed Oct 21, 2015 9:25 pm

Hi,

smtplib does work because that's what I used for the KS videos... but it needs a bit of tweaking. I will clean it up and make it public soon.

Cheers,
Daniel

Ferretproof
Posts: 8
Joined: Sun Oct 11, 2015 4:56 pm

Re: Sending email

Post by Ferretproof » Wed Oct 21, 2015 9:58 pm

Great, that is good news. I (we?) will wait for that.

lucien2k
Posts: 24
Joined: Sun Oct 11, 2015 5:34 pm

Re: Sending email

Post by lucien2k » Thu Oct 22, 2015 8:06 am

urllib is another library that would be useful, I was planning to use a rest api to push data from the wipy to a central system.

I had a brief play with it because I figure it is 99% sockets and it is pure python, but if you already have something working that would be great.

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: Sending email

Post by danicampora » Thu Oct 22, 2015 8:08 am

I agree, urllib will be great as well.

Ferretproof
Posts: 8
Joined: Sun Oct 11, 2015 4:56 pm

Re: Sending email

Post by Ferretproof » Thu Oct 22, 2015 8:38 am

That would be award winning, especially when it also supports HTTPS.
(tell me when I ask too much :D)

Post Reply