Jump to content
jgingras

Php Mail() Not Delivered

Recommended Posts

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

Share this post


Link to post
Share on other sites

You need to authenticate sending.

 

>mail("xxx@xxxxx.com","Test Email",$Message,$headers  "-f".$myemail);

Share this post


Link to post
Share on other sites
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 by jgingras

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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 by jgingras

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

It is a fifth parameter, so it should be:

 

>mail($to, $subject, $msg, $headers, "-fsupport@piazza.cc");

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 by jgingras

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...