Mail() not sending to some address (and not in Junk folder)

Hi,

I’m using the mail() function to send emails from a contact form on a php site. It works perfectly for hotmail and yahoo addresses but not my work address (nothing arrives, ever) It doesn’t go to a junk or spam type folder either.

Is there a parameter I’m missing or something I should be adding to ensure it is treated as mail correctly by my work email server?

Or is there a better function I can use?

The code I’m using is:


$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['txt_Name'];
$visitormail = $_POST['txt_Emailaddress'];
$notes = $_POST['txtarea_Message'];

if (eregi('http:', $notes)) {
	die ("Sorry, this action is not allowed. If you feel this is a mistake, please <a href='mailto:contact@davidlavery.co.uk' class='textLink'>email us</a> directly.");
}
if((!strstr($visitormail,"@") || !strstr($visitormail,"."))) {
	$badinput = "Fail";
}

$toAddress = 'derek.smith@mywork.com';
$subject = "Website query";
$todayis = date("l, F j, Y, g:i a") ;
$notes = stripcslashes($notes);
$message = " $todayis \
\
Message: $notes \
From: $visitor ($visitormail)\
";
$from = "From: ".$visitormail."\\r\
";

if(($visitor != "") && ($visitormail != "") && ($notes != "") && ($badinput != "Fail")) {
mail($toAddress, $subject, $message, $from);

Many thanks for your help,
Des

After a while of “trying to get it right” with mail() along with following RFC 1896, 2045, 2046, 2047, 2048, 2049, 2822 etc… I’ve decided to use swift-mailer to comply to those standards for me.

yup most of the we have found that you use plain mail function you end the things up in junk folder with ip being partially blacklisted…
so i also recommend using some stanadard apps like phpmailer

plus,only 1-2 are not being sent means rather than script problem it may be server-server problem (can be many …mail server not responding…,mail filter on remote servers and so on…)
using some other tools and investigating returned code from that mail server can be of some help

Grand, I’ll give it a try.

Thanks for your help, D