L-36.com

Sending emails with the ESP32-SIM800

It is the hard way but it works


esp32/ESP32-SIM800.jpg

I looked on Google for hours trying to find how to send emails with the ESP32-SIM800 from TTGO T-Call. The problem is that the unit is faulty and can't send emails. But we are sending emails from this little ESP32 to our home accounts. It is not straight forward and takes requires access to a server but it works.

The function that does work is the ability to read a web page and that is the function we used. We put the text for the email in the query field of the request to a special web page and had that page send the email to our home account. Simple, but you need access to a server running php. Luckily most all servers can do that. The required page is simple enough that you can likely get a friend to host it for you.

Here is the Arduino code which is a modified version of the code in the excellent tutorial HERE.

Arduino Code

const char resource[] = "?password=myPassword&message=";
String message = "GET ";
message += resource;
message += statusMessage;
message += " HTTP/1.0\r\n";
Serial.print("Message is ");
SerialMon.println(String(message));
// Make a HTTP GET request: client.print(message);
client.print(String("Host: ") + server + "\r\n");
client.print("Connection: close\r\n\r\n");
The server gets the following PHP code.

Server Code

<? $password = trim(strip_tags($_REQUEST['password']));
$message = trim(strip_tags($_REQUEST['message']));
$headers = "From: ESP32-SIM800" . "\r\n";
if($password == "myPassword"){ mail ("myAddress@gmail.com", "Report", $message, $headers);
mail ("debug@gmail.com", "ESP32 Report", $message, $headers);
echo "Message sent";
} else { echo "password incorrect <
br>";
$message .= " password = " . $password;
mail ("debug@gmail.com", "ESP32 Report", $message, $headers);
} ?>


NOTICE: Some pages have affiliate links to Amazon. As an Amazon Associate, I earn from qualifying purchases. Please read website Cookie, Privacy, and Disclamers by clicking HERE. To contact me click HERE. For my YouTube page click HERE