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? 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 Aug 25 '15 at 22:08

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:


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:




End IMAP session with:

. logout

For experiments from Windows using telnet:

telnet mailserver.domain.com 143



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.