[SOLVED] mail() function not sending email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

[SOLVED] mail() function not sending email

Post 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?
Last edited by Bill H on Tue Oct 11, 2005 9:56 am, edited 1 time in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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?
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post 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.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Try two "\r\n" (i.e. "\r\n\r\n")
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 :?
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post 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.
Post Reply