Pages: [1]   Go Down
Author Topic: Email Timing Issue  (Read 1978 times)
0 Members and 1 Guest are viewing this topic.
Boston
Offline Offline
God Member
*****
Karma: 3
Posts: 574
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I have a project that uses an Arduino & a WiShield to connect to my home network.
This then sends me an email via a PHP page at regular intervals like twice a day.
The email contains a timestamp. 
Sometimes I don't get the email until hours later, but it always has the right timestamp.
The PHP page is on a server on the Internet, not inside my home.
What would cause the email to be delayed for hours?
Is this a PHP or server issue?

Thanks.

Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, there is the usual suspect.  Misbehaving internet service provider.

Are you closing the session to the email server cleanly?  I vagualy recall that sending email requires a "quit" when finished.
Logged

Vejen, Denmark
Offline Offline
Edison Member
*
Karma: 7
Posts: 1178
RAWR! ^,..,^
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

How are you sending it?

With php it should be as simple as
Code:
$to = "recipient@example.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

if (mail($to, $subject, $body))
{
    echo("<p>Message successfully sent!</p>");
}
else
{
    echo("<p>Message delivery failed...</p>");
}
I am using this with success myself.

Are you sending more than just a few emails with this daily? Wondering if there could be some kind of limit on it, so it can't be used for spam.
Logged

captain-slow.dk | non contagious!

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I forgot about "mail".  Ignore my post.
Logged

Boston
Offline Offline
God Member
*****
Karma: 3
Posts: 574
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am using the following :
if ( mail($tot,$subject,$message,$headers,"From: $from\nContent-Type: text/html; charset=iso-8859-1") ) {

   echo "Yahoo!";
   } else {
   echo "The email has failed!";
   }
Logged

Southern Ontario
Offline Offline
Sr. Member
****
Karma: 2
Posts: 279
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just be sure that you hide the url to that page... sending mail via php is very risky without input sanitation... You could have your script co-opted as a spambot....
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 137
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

not sure if this is connected, but i am kinda having the same problem.  i have a telnet server set up on the arduino and when a specific command is sent to it, it sends a get command to the php site which the php site then uses to compare against a mysql page which then sends out an email to a specific address...anyhow the problem i'm having is that i run the command, email goes out, run it again and email goes out, third time and on, connection to the php server fails and nothing goes out.  maybe this is your problem as well, maybe the connection is failing and then later going out again once the connection is re-established.  just a thought
Logged

Boston
Offline Offline
God Member
*****
Karma: 3
Posts: 574
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the suggestions.
I don't think the problem is establishing a connection as the timestamp is correct.
Probably a server issue which I can do nothing about.
What is the proper way to hide the URL?
Logged

Southern Ontario
Offline Offline
Sr. Member
****
Karma: 2
Posts: 279
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the proper way to hide the URL?

Just make it hard to guess by humans or robots, and don't ever post a link to it on a page that gets crawled by a search engine.

example.com/faldjfsdljkdf/asdlfsdkjfdfjk.php should work...
Logged

Pages: [1]   Go Up
Jump to: