Arduino with eternet start php

Hi,
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.

Thanks.

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);
  Serial.begin(9600);
 delay(1000);

  Serial.println("connecting...");

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

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
      ;
  }
}

now I try with 1.1
and get this

connecting...
connected
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

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.

</p>
</body></html>

disconnecting.

It did not understand this:

    client.println("Host: http://www.testiranja.site50.net\r\n");

But it should understand this:

    client.println("Host: www.testiranja.site50.net");

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:

    Serial.println("connected");
    client.write("GET /arduino.php HTTP/1.0\r\n");
    client.write("Host: www.testiranja.site50.net\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

<?php
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      = 'm.s@gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From:m.s@gmail.com' . "\r\n" .
    'Reply-To: milan.samardzic@gmail.com' . "\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 !?