jgingras Posted June 5, 2008 Share Posted June 5, 2008 I'm having problems with the mail function. The basic php mail is using the nobody@servername.com and some mail clients seem to be rejecting the mail, either putting it in spam or rejecting it all together. How come is this the case? How can I change my settings or headers so that this doesn't take place? Thanks, -Jacques Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted June 5, 2008 Share Posted June 5, 2008 You need to authenticate sending. >mail("xxx@xxxxx.com","Test Email",$Message,$headers "-f".$myemail); Quote Link to comment Share on other sites More sharing options...
jgingras Posted June 5, 2008 Author Share Posted June 5, 2008 (edited) You need to authenticate sending. >mail("xxx@xxxxx.com","Test Email",$Message,$headers "-f".$myemail); Is that a 5th parameter to mail() or a string that I put right after the headers? Also, is there a way to make it so that it doesn't use the nobody@servername? Here is the header that resulted from me doing the line above. Return-path: <support@piazza.cc> Envelope-to: support@piazza.cc Delivery-date: Thu, 05 Jun 2008 16:08:47 -0400 Received: from nobody by server01.piazza.cc with local (Exim 4.68) (envelope-from <support@piazza.cc>) id 1K4LlP-0000WJ-1w; Thu, 05 Jun 2008 16:08:47 -0400 To: support@piazza.cc the return path was fixed, but the received part of the header is still from nobody.. not sure exactly how to fix this. Edited June 5, 2008 by jgingras Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted June 5, 2008 Share Posted June 5, 2008 If you add the "-f".$myemail and use the email address you want the mail sent from the nobody@server will disappear. It goes right after $headers Quote Link to comment Share on other sites More sharing options...
jgingras Posted June 5, 2008 Author Share Posted June 5, 2008 (edited) If you add the "-f".$myemail and use the email address you want the mail sent from the nobody@server will disappear. It goes right after $headers this is the line of code that calls the mail. >mail($to, $subject, $msg, $headers "-f support@piazza.cc"); it gives me the following error. Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING. should it be >mail($to, $subject, $msg, $headers . "-f support@piazza.cc"); OR >mail($to, $subject, $msg, $headers, "-f support@piazza.cc"); Edited June 5, 2008 by jgingras Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted June 5, 2008 Share Posted June 5, 2008 Change it to this: >mail($to, $subject, $msg, $headers "-f".support@piazza.cc); note the placement of the closing quote! I don't know if you have to escape the @ sign or not. I usually set it to a variable as I posted originally. Quote Link to comment Share on other sites More sharing options...
click Posted June 6, 2008 Share Posted June 6, 2008 It is a fifth parameter, so it should be: >mail($to, $subject, $msg, $headers, "-fsupport@piazza.cc"); Quote Link to comment Share on other sites More sharing options...
OJB Posted June 6, 2008 Share Posted June 6, 2008 when I use the php mail function mine was like this: mail($to, $subject, $msg, "FROM: support@piazza.cc"); this seems to work for all my messages. Quote Link to comment Share on other sites More sharing options...
jgingras Posted June 6, 2008 Author Share Posted June 6, 2008 (edited) Thanks everyone. I set it as the fifth parameter and it helped some because now it isn't sent in my spam folder. The Return path, and envelope-from is correct. However there is one part of the headers that im not sure if it could still be a problem for some mail clients. Here is what it says.. Received: from nobody by server01.piazza.cc with local (Exim 4.68) (envelope-from <support@piazza.cc>) id 1K4VAt-0004XV-Fi; Fri, 06 Jun 2008 02:11:43 -0400 Since it says that it is received from nobody, will this still cause some mail servers to reject the mail? Thanks, -Jacques Edited June 6, 2008 by jgingras Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted June 6, 2008 Share Posted June 6, 2008 Some servers will reject form mail regardless of what you do. Quote Link to comment Share on other sites More sharing options...
jgingras Posted June 6, 2008 Author Share Posted June 6, 2008 Is there any way to "trick" the servers into thinking that an actual user send the mail? What is PHPSuexec? Might this be able to help me to make everything more secure as a whole? Thanks, -Jacques Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.