uMail - A lightweight SMTP client for MicroPython
-
- Posts: 13
- Joined: Thu Nov 03, 2016 10:12 pm
Re: uMail - A lightweight SMTP client for MicroPython
The issue appears to have been with MicroPython.
After flashing the latest build from
http://micropython.org/resources/firmwa ... 0abcf2.bin
umail worked again
After flashing the latest build from
http://micropython.org/resources/firmwa ... 0abcf2.bin
umail worked again
Re: uMail - A lightweight SMTP client for MicroPython
I have fallen at the first fence. How do you set up the "import umail" on an ESP32 development board?
I am using uPyCraft from a Windows 10 PC to talk to the ESP32. I have flashed micropython to the board and run a simple micropython program to flash an LED on the board, so that works. I have downloaded the umail zip file to the PC from Github and extracted the files, which mainly consists of the umail.py python script.
But what do I do now??
I am using uPyCraft from a Windows 10 PC to talk to the ESP32. I have flashed micropython to the board and run a simple micropython program to flash an LED on the board, so that works. I have downloaded the umail zip file to the PC from Github and extracted the files, which mainly consists of the umail.py python script.
But what do I do now??
Re: uMail - A lightweight SMTP client for MicroPython
OK I've got this fully working now, so ignore the previous post. For the benefit of any other novices, this is what you do:
1 From Github (address provided in this topic above), go to CODE and download the zip file. This contains the software.
2 Unzip it and place the contents in the "workspace" folder on your PC (I am assuming you are using uPyCraft IDE, which is very good).
3 In uPyCraft, open (File/Open) the umail.py file and Download it (Tools/Download). This installs it into the device folder.
4 In a python script, try "import umail". This should work.
5 Carry on with the other tutorials, which explain how to send an email. For me, this worked first time.
I must congratulate the author on a very handy little module. I will use it to notify myself via email of any changes to the parameters I will be monitoring. I may also set up a web server to monitor directly should I need to.
1 From Github (address provided in this topic above), go to CODE and download the zip file. This contains the software.
2 Unzip it and place the contents in the "workspace" folder on your PC (I am assuming you are using uPyCraft IDE, which is very good).
3 In uPyCraft, open (File/Open) the umail.py file and Download it (Tools/Download). This installs it into the device folder.
4 In a python script, try "import umail". This should work.
5 Carry on with the other tutorials, which explain how to send an email. For me, this worked first time.
I must congratulate the author on a very handy little module. I will use it to notify myself via email of any changes to the parameters I will be monitoring. I may also set up a web server to monitor directly should I need to.
Re: uMail - A lightweight SMTP client for MicroPython
how to send via umail, attachments?
Re: uMail - A lightweight SMTP client for MicroPython
tom1,
Find anything? I finally got uMail to work on the ESP32 and now I also want to send attachments. I use sendmail in a Python script on a RaspberryPi. Had a pretty good look around and all the tutorials I see use sendmail.
Dave
Find anything? I finally got uMail to work on the ESP32 and now I also want to send attachments. I use sendmail in a Python script on a RaspberryPi. Had a pretty good look around and all the tutorials I see use sendmail.
Dave
Re: uMail - A lightweight SMTP client for MicroPython
Subject line.
Has anyone incorporated a subject line in uMail and that they are willing to share?
Thanks,
Dave
Has anyone incorporated a subject line in uMail and that they are willing to share?
Thanks,
Dave
-
- Posts: 463
- Joined: Wed Apr 08, 2015 5:19 am
Re: uMail - A lightweight SMTP client for MicroPython
@davef: uMail does not format the email for you. It is equivalent to the "smtplib" module in the CPython standard library. If you want a subject or any other header, you need to format an RFC5322-compliant message string. On CPython your would do this with the "email" module, but that is much too big to be ported to MicroPython.
You can read about the basics of the internet message format on Wikipedia: https://en.wikipedia.org/wiki/Email#Int ... age_Format
If you want attachments, you need to format an RFC2045-compliant multipart message string.
You can read about the basics of the internet message format on Wikipedia: https://en.wikipedia.org/wiki/Email#Int ... age_Format
If you want attachments, you need to format an RFC2045-compliant multipart message string.
Re: uMail - A lightweight SMTP client for MicroPython
@SpotlightKid,
With some help here:
viewtopic.php?f=11&p=50054#p50054
I have the subject line issue sorted.
I will now read about
Thanks for that.
Dave
With some help here:
viewtopic.php?f=11&p=50054#p50054
I have the subject line issue sorted.
I will now read about
as attaching a .csv file will be easier than copying up to 120K of text in a text editor and giving it a .csv name.RFC2045-compliant multipart message string
Thanks for that.
Dave
Re: uMail - A lightweight SMTP client for MicroPython
In a working Python email application I have:
Appears the first thing required is MIMEbase. Looked around and found this:
https://pypi.org/project/mime/#files
Can't see the keyword attach or attachment in the source. Also, looks like I would need:
MIMEMultipart() to be able to get <msg>. It is not clear to me if this source could do what I want.
Can anyone point to an easier method of attaching files to a Gmail SMTP message?
Thanks,
Dave
Code: Select all
# open the file to be sent
filename = my_file
attachment = open(my_file, 'rb')
# instance of MIMEBase and named as p
p = MIMEBase('application', 'octet-stream')
# To change the payload into encoded form
p.set_payload((attachment).read())
# encode into base64
encoders.encode_base64(p)
p.add_header('Content-Disposition', 'attachment; filename= %s' % filename)
# attach the instance 'p' to instance 'msg'
msg.attach(p)
https://pypi.org/project/mime/#files
Can't see the keyword attach or attachment in the source. Also, looks like I would need:
Code: Select all
# instance of MIMEMultipart
msg = MIMEMultipart()
Can anyone point to an easier method of attaching files to a Gmail SMTP message?
Thanks,
Dave
Re: uMail - A lightweight SMTP client for MicroPython
Just in case you might want to do an attachment. Go to https://github.com/shawwwn/uMail/issues/2 and in the example by varna9000 change the lines:
For a specific dated .csv file I changed them to:
Code: Select all
smtp.write("Content-Type: image/jpeg; name=cam.jpeg\n")
smtp.write("Content-Disposition: attachment; filename="cam.jpeg"\n")
Code: Select all
# build today's filename into Content-Type and Content-Disposition
csv_file = 'House-' + date + '.csv\n'
content_type = 'Content-Type: text/csv; name=' + csv_file
content_disposition = 'Content-Disposition: attachment; filename=' + csv_file
smtp.write(content_type)
smtp.write(content_disposition)