Arduino with eternet start php

I wrote php script to send e-mail. Now I need from my arduino uno R3 and eternet shield to start that script. I use free hosting on 000webhost. I try all day, but only what I get is Connected and similar staff, no email. I try to open php page from browser and in that case send email and work fine. Also I try to make one html page with form (textbox and Submit), and send data in that field and push Submit but nothing happened. In the best case I need to send data from arduino pin (HIGH or LOW) to my email.


You should post your Arduino code.

sorry I try many thing today, now I try with this

#include <Ethernet.h>
#include <SPI.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 20 }; //my router IP
byte server[] = {31, 170, 162, 243}; // My webserver IP

EthernetClient client;

void setup()
  Ethernet.begin(mac, ip);


  if (client.connect(server, 80)) {
//    client.print("GET /arduino.php HTTP/1.0");
    client.println("GET /arduino.php HTTP/1.0\r\n");
    client.println("Connection: close\r\n");
    Serial.println("Sent the http request");
  } else {
    Serial.println("connection failed");

void loop()
  if (client.available()) {
    char c =;

  if (!client.connected()) {

now I try with 1.1
and get this

Sent the http request
HTTP/1.1 400 Bad Request
Date: Mon, 13 Jan 2014 20:25:32 GMT
Server: Apache
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1

<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.



It did not understand this:


But it should understand this:


And stop putting a blank line after every line. That is a signal the header is complete, and it isn't. Like this:

    client.println("GET /arduino.php HTTP/1.0\r\n");

That is NOT then end of the header, but your server thinks it is.

Use this instead:

    client.write("GET /arduino.php HTTP/1.0\r\n");
    client.write("Connection: close\r\n\r\n");
    Serial.println("Sent the http request");

And thats work.

Thank you verry much, man ! You have beer or something if you get in Sarajevo :-).

One more question, if I want to send certain message in that e-mail for example state of button, how to do that? I want to set body message to High or Low or some random text from arduino?
My php is

header("Content-type: text/html");
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past

     $to      = '';
$subject = 'the subject';
$message = 'hello';
$headers = '' . "\r\n" .
    'Reply-To:' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();


Can I in arduino write some code like
push $message= + "some text or button state"

It would be a pleasure to have a beer with you. I'm having one now, so if you are also, we are having a beer together on the internet. :slight_smile:

I posted a response to your other post. The ip you got from the nslookup worked for me.

edit: I don't know about the php code, but you can with my code.

// replace this...
client.write("This is from my Arduino!\r\n");
// with this:
client.write("Some text or button state\r\n");

Thank you for helping.

I try to send custom message but didn't success. I alredy have predefined text in php script, now I don't know how to add/change message body. I thinking about posting data in some kind of form and when arduino click "submit" I got mail with data !?