Most of the currently available solutions for sending a simple email with arduino are bit complicated for my taste. Like knowing your SMTP server ip and the converting your password and username to bas64 like whaaat no way, ain’t nobody got time for that.

So here is a solution, BUT there are couple of small BUT-s you have to have access to some kind of web hosting solution. (There are plenty of free hosting solutions out there, like googling + registration = 3 min. I tested 😉 ). And the hosting solution has to have smtp enabled on php or supported (I didn’t find any that didn’t work). And I will show you how to check that.
We will use: Arduino Uno and WizNet W5100 ethernet shield.

  1. First we will create a php file that will send the email. Code for php is following:
          <title>Sending HTML email using PHP</title>
             $to = "";       //Receiver email.
             $subject = "Arduino";
             $message = $_GET['text'];               //Text variable will be the message content
             $header = "From: Arduino\r\n";
             $header .= "Cc:\r\n";
             $header .= "MIME-Version: 1.0\r\n";
             $header .= "Content-type: text/html\r\n";
             $retval = mail ($to,$subject,$message,$header);
             if( $retval == true ) {
                echo "Message sent successfully...";
             }else {
                echo "Message could not be sent...";


  2. Code is pretty straight forward. Just replace “” with the email where you want to receive the messages.
  3. Copy code to the file to the text file and save it as sendmail.php
  4. Upload it to your web hosting service. And with your browser navigate to it AND at the end of the address add “?text=test”. So address looks something like that “http:\\\sendmail.php?text=test“. If server supports sending mail via php you will receive the “Message send successfully…”. Message. And if you check your email, there should be new mail with subject Arduino.
  5. Next Arduino sketch:
    #include <SPI.h>
    #include <Ethernet.h>
    byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
    char server[] = "";    // your domain
    // Set the static IP address to use if the DHCP fails to assign
    IPAddress ip(192, 168, 8, 120);
    // Initialize the Ethernet client library
    // with the IP address and port of the server
    // that you want to connect to (port 80 is default for HTTP):
    EthernetClient client;
    void setup() {
      // Open serial communications and wait for port to open:
      while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB port only
      // start the Ethernet connection:
      if (Ethernet.begin(mac) == 0) {
        Serial.println("Failed to configure Ethernet using DHCP");
        // try to congifure using IP address instead of DHCP:
        Ethernet.begin(mac, ip);
      // give the Ethernet shield a second to initialize:
      // if you get a connection, report back via serial:
      if (client.connect(server, 80)) {
        // Make a HTTP request:
        client.println("GET /sendmail.php?text=whadap HTTP/1.1");
        client.println("Host:");                   //your domain
        client.println("Connection: close");
      } else {
        // if you didn't get a connection to the server:
        Serial.println("connection failed");
    void loop() {
      // if there are incoming bytes available
      // from the server, read them and print them:
      if (client.available()) {
        char c =;
      // if the server's disconnected, stop the client:
      if (!client.connected()) {
        // do nothing forevermore:
        while (true);

    Don’t forget to change the domain info  in the sketch.

  6. Upload the sketch to arduino.
  7. Open arduino serial monitor and you should see the text output from arduino “conncecting…” “connected” “disconnecting”
  8. Check your mail and confirm that the mail was delivered.


  1. If you don’t see the output from arduino serial monitor press the reset button on arduino. The script is only executed once when the arduino starts.
  2. Don’t forget to check your spam folder for the mail.

That’s it. It is super simple way to quickly set up mail sending on arduino.