async service to check an imap's folder and POST it to an http service
338
async service that will check an imap folder and send them to an http service
If you want to test it / modify it in a clean environment
There's one provided (if you have docker and vagrant on your machine), it's as simple then as doing
vagrant up
vagrant ssh
You can either use the docker image
docker push allansimon/py-imap-to-http
or run the project using
python3 -m service
it will check your INBOX (or other folder you've configured), iterate over the emails, POST a http form (with attachments if any) to the specified url.
In case your http service responsed a 2XX, it will then move the email to a success folder, otherwise it will move it to a error (both can be configured)
It will also treat emails as soon as they are received in an efficient manner (using the IDLE capacity of IMAP and not some ugly sleep hacks)
IMAP_SERVER : imap server to check (e.g imap.gmail.com)IMAP_USER : user to use to connect to the imap (e.g [email protected])IMAP_PASSWORD : user's password (e.g [email protected])IMAP_CHECK_FOLDER: folder to observe (by default INBOX)IMAP_SUCCESS_FOLDER: email treated successfully will be moved thereIMAP_ERROR_FOLDER: email treated with errors will be moved thereIMAP_POST_TO_URL: the emails will be POSTed one by one to this address as if you had submitted a HTML form.The IMAP_POST_TO_URL should be able to treat a multipart/url-encoded POST (i.e traditional HTML form, like it's the 90s all over again, why reinventing the wheel...) with the following form's fields:
from: the email it's fromto: the email it's frommessage_id: the imap server's id associated to the emailbody: the plain text bodyin case of attachments you will have the following additional fields:
attachments[0] , attachments[1] etc.If you want an additional fields to be treated, or if you want the POST to be configured to be a PUT, or to submit it as JSON/XML/etc. feel free to open a merge request
Content type
Image
Digest
Size
41.1 MB
Last updated
almost 6 years ago
docker pull allansimon/py-imap-to-http