1

Is there a sketch that supports the receiving of email using the Arduino environment on the ESP8266? I can only find support for sending email. I know it's possible because the NodeMCU environment supports it. Any help is appreciated!

  • receiving e-mail as in acting as an e-mail server, or simply pulling e-mail from another server? – user2813274 Aug 25 '15 at 20:19
  • Pulling email from another server – Sam W Aug 25 '15 at 20:25
  • In that case it depends on the interface of the other server that you are pulling the mail from - the easiest might be from a web interface, in which case something like this could work – user2813274 Aug 25 '15 at 22:08
1

Once you know how to connect to any server and send messages to it, retrieveing emails is just a matter of sending right messages (=commands).

Here below follows an "IMAP tutorial", i.e. guide to which commands to send to an IMAP server to search and retrieve messages.

Note: once you connect to the IMAP server, the first command to send is the login command:

foo login user password

"foo" is just a session identifier, not a keyword. "login" is the keyword.

Once you get the welcome message, you can start sending more commands:

Select the proper folder:

. SELECT "INBOX"

Look for desired message (strings are always considered substrings, so no wildcards are needed):

. SEARCH FROM "user@example.org" SUBJECT "some keywords here"

This will result in list of matching messages, with search results formatted as follows:

* SEARCH 5 10 456

This means messages n.5, n.10 and n.456 match the query.

If examining just the subject (which may contain keywords and switch as required) is not enough, the whole body can be retrieved, both marking the message as read or leaving it untouched:

. FETCH 5  BODY[TEXT]

or

. FETCH 5  BODY[TEXT].PEEK

End IMAP session with:

. logout

For experiments from Windows using telnet:

telnet mailserver.domain.com 143

Reference:

https://www.skytale.net/blog/archives/23-Manual-IMAP.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.