Page 1 of 1

[SOLVED] mail() function not sending email

Posted: Mon Oct 10, 2005 7:03 pm
by Bill H
This is the entire script, with three alternate $header lines as suggested by the hosting company. Nono of them are sending the email.

Code: Select all

<?php

$Content = "Date: " . stripslashes($_POST['Date']) . "\n\n";
$Content .= "Email: " . stripslashes($_POST['Email']) . "\n\n";
$Content .= stripslashes($_POST['Msg']) . "\n";

// original, which has worked on a different server at the same hosting company
$MailTo = "me@myemail.com";
$Subject = "Calendar Addition";
$MailFrom = "auto@whatever.org";
mail($MailTo, $Subject, $Content, "From: $MailFrom");

// first suggestion from hosting support -- didn't work
mail($MailTo, $Subject, $Content, "From: $MailFrom", "-f$MailFrom");

// second suggestion from hosting support -- no joy
$headers = "MIME-Version: 1.0\n" ;
$headers .= "From: auto@whatever.org\n";
mail("me@myemail.com", "Calendar Addition", $Content, "$headers");

// not sure why the 4th parameter is in quotes, so I tried
mail("me@myemail.com", "Calendar Addition", $Content, $headers);
// which also did not work

header("Location:calendar.php?Okay=1");
?>
The hosting support has now stopped responding to me, so I presume they are stumped. Does anyone here have any ideas?

Posted: Mon Oct 10, 2005 7:09 pm
by Chris Corbyn
Not sure. Apart from the usual spam blocking etc....

Try having two newline characters on you last header line... I believe that's standard but PHP probably puts a break in there for you anyway :?

How many accounts (domains rather) has this failed on?

Posted: Mon Oct 10, 2005 7:20 pm
by feyd
may want to swap \n to \r\n in the header (at least) but that's a stab in the dark..

are there any errors you are getting? Have you tried various servers to sent to? Has the email "accidentally" been dumped into a spam/junk bin?

Posted: Mon Oct 10, 2005 7:43 pm
by Bill H
Tried "\n\n" on the end of $header and "\r\n" both. Mail is definitely not getting dumped into junk mail bin, I check for receipt using a webmail client that does not have any such critter.

I think it is a server setting, personally, and my host is laying low. I host five sites with this company and all are one of two servers that I like while this one got put on a different server that I have no experience with. I have a feeling I need to harass them some more, but I wanted you guys to check to be sure I'm not missing something in the code.

Not now, tho. It's almost time for the Chargers to take on the Steelers on MONDAY NIGHT FOOTBALL.

Posted: Tue Oct 11, 2005 8:40 am
by Jenk
Try two "\r\n" (i.e. "\r\n\r\n")

Posted: Tue Oct 11, 2005 9:04 am
by Chris Corbyn
Hmm... if it was configuration issue you would probably see errors. Is it a linux server? If it is then it should probably just work by sendmail. Windows servers I suppose could have incorrect SMTP settings though. The only other thing I can think of is that the server has the SMTP port closed by a firewall mistakenly :?

Posted: Tue Oct 11, 2005 9:55 am
by Bill H
I just got this from mi hosting support, sent myself a test email, and it does work.
I upgraded Exim on the server and tested our script with your email and it sent from
our server.