Why Doesn't My Php Mail() Work?

I am having a problem sending email through PHP's built-in mail function. I can send to my address at home, but not to my address with the domain i have hosted with you. Let's say my domain with you is "****".<br /><br />here is my code:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$from = "Webmaster";<br />    $mailfrom = "sarah@****";<br />    $emailto = "sarah@****";<br />    $subject = "My Subject";<br />    $message = "my message";<br />    $headers = "Content-type: text/html; charset=iso-8859-1\r\n";<br />    $headers .= "From: ".$from." <".$mailfrom.">\r\n";<br />    $headers .= "Reply-to: $mailfrom";<br />    $headers .= "X-Priority: 3\r\n";<br />    $headers .= "X-Mailer: PHP4\n";<br /><br />    ini_set(sendmail_from,$mailfrom);<br />    <br />  if (@mail($email, $subject, $message, $headers)){<br />      print "<a href=http://www.totalchoicehosting.com/forums/lofiversion/index.php/'login.php'>Login</a><br>";<br />      print "Your password was emailed to you. Please check your email within a few minutes.";<br />      ini_restore(sendmail_from); <br />  }<br />  else{<br />      print "Your password could not be emailed.. Please contact your system admin or try again.";<br />      exit;<br />  }<!--c2--></div><!--ec2--> <br /><br />Can anyone help me identify what's going on? I tried everything, and I don't want to use someone else's code if there's a small fix. Please help!<br /><br />Sarah<!--content-->
I've looked over your code and it looks well written. I've also used mail() to send email to me at <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --><br /><br />The only thing I can think of...<br /><br />1- Why are you using ini_set? I see what it does but maybe you could try commenting it out of you script to see if that helps.<br /><br />2- Has your site fully propagated? Can you send email from your home account to <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->?<br /><br />If neither of those are the issue, then I'd submit a help ticket. There is a very small possiblity that something at the server level needs looking at. I ran into a similar issue and it turned out that the email server and my webserver were set differently.<br /><br />TCH tech support is very good.<!--content-->
I'm receiving email fine if I send to myself from my home account. Maybe it has something to do with the MX record for my email being set to a different server than one at TotalChoice?<br /><br />We are using our own email server, which has a Lotus Notes Email Program. <br />I can't imagine why else it wouldn't be working. I don't get any error messages.<br /><br />I've taken out the ini_set commands, I was using it to set the mailfrom to make sure things would get there from me instead of the default "nobody". I guess I will submit a help ticket since I can't figure out what else to do.<br /><br />Sarah<!--content-->
Apparently, the mail was going to my account on TCH locally, instead of directing it out to my own mail server, even though the MX records were pointing to the right server. <br />All the mail that was sent showed up in my webmail box!!<br /><br />I submitted a help desk ticket and we got it straightened out. Now i'm trying to figure out how to make the "[email protected]" disappear from the "from" field.<br /><br />Thanks for the help!<!--content-->
Sarah I am not sure but this <a href="http://www.totalchoicehosting.com/forums/index.php?showtopic=2534&hl=nobody@server" target="_blank">thread</a> may help.<!--content-->
Ok, <br />I checked the thread and I understand that.. But how could I send all the other headers while putting that 4th parameter in?<br /><br />Should i put:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->mail($mailto,$subject,$message,$headers,From: $mailfrom)<!--c2--></div><!--ec2--><br /><br />or something like that? I don't think it handles 5 parameters.<!--content-->
I got it!!!!!! YAYYA!<br /><br />I read some posts on php.net and found that the "\r" only works for Windows-based servers using SMTP. (my old web host used that). So I took them out and added the From header and it worked!! Hooray!! <br /><br />Here's the code:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$mailfrom = "sarah@****";<br />    $emailto = "sarah@****";<br />    $subject = "subject";<br />    $message = "message";<br />    $headers = "Content-type: text/html; charset=iso-8859-1\n";<br />    $headers .= "From: $mailfrom\n";<br />    $headers .= "Reply-to: $mailfrom\n";<br />    $headers .= "X-Priority: 3\n";<br />    $headers .= "X-Mailer: PHP4\n";<br />  <br />    if (@mail($emailto, $subject, $message, $headers)){<br />      print "<a href=http://www.totalchoicehosting.com/forums/lofiversion/index.php/'login.php'>Login</a><br>";<br />      print "Your password was emailed to you. Please check your email within a few minutes.";<br /><br />  }<br />  else{<br />      print "Your password could not be emailed.. Please contact your system admin or try again.";<br />      exit;<br />  }<!--c2--></div><!--ec2--><br /><br />Thanks everyone.<br /> Rock Sign <br />PS - hey Rick, I have a parrot just like the one in your photo!<!--content-->
Does that mean you have solved the nobody@ problem?<br /><br />Any way congrats on fixing it the php, and don't be a stranger <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
Yep, solved the <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --> . <br /><br />Hopefully this will help anyone else having the same problems.<br /><br />C-ya around.<!--content-->
Thanks for the info<!--content-->
 
Top