ESP8266 and envelope image

Once you have an application running on your ESP8266, you may want it to send an email to alert someone to a problem with a sensor or to send a regular status report, etc. Email is simple to set up on the ESP8266 and this article presumes you already have an e-mail account that you can send emails from. You'll need to gather together the following information to customise the sketch for your own purposes:

You can download the example sketch here. It's heavily commented to explain each step of setting up the mail conversation with the server. You'll notice that character strings appear as F("string") - F() is a macro that ensures that the string is stored in flash memory rather than taking up space in RAM.

Using the ESMTP (Enhanced SMTP) protocol means that you will need to encode your email login username and password in base64 before pasting it into the sketch. Encoding in base64 is a process whereby a string of characters is encoded into another string that contains only 64 basic ASCII characters. It is used mainly to encode binary strings so that they can be transmitted in a simple subset of ASCII across possibly unpredictable channels without the risk of corruption or being interpreted as control characters.

You can encode your strings into base64 here.

A list of SMTP commands is summarised here.