scott_m Posted September 16, 2008 Share Posted September 16, 2008 This mail function is being used for a send to friend page. When I call the function, instead of just sending to the recipient, it also sends the same email to the sender. Any ideas why this would happen? function SendMail( $theFrom="", $theTo="", $theSubject="", $theMessage="") { $headers = 'From: ' . $theFrom . ";\n"; $headers .= 'Content-type: ' . $theType . ";\n"; $headers .= "Reply-To: $theFrom\n"; $headers .= "X-Mailer: PHP/".phpversion(); mail($theTo, $theSubject, $theMessage, $headers, "-f$theFrom"); } SendMail("My Name <[email protected]>", "[email protected]", "test subject", "test message", "text/html"); The email is being sent "on behalf of" the domain on the server. Could that be the reason? Is there something I can put in the headers? something that needs to get changed in server settings? Any ideas? Thanks, Scott Link to comment https://forums.phpfreaks.com/topic/124544-solved-mail-function-sending-email-to-both-sender-and-recipient/ Share on other sites More sharing options...
DarkWater Posted September 16, 2008 Share Posted September 16, 2008 You're using the wrong parameters for mail(). Here: http://us2.php.net/manual/en/function.mail.php Link to comment https://forums.phpfreaks.com/topic/124544-solved-mail-function-sending-email-to-both-sender-and-recipient/#findComment-643195 Share on other sites More sharing options...
cooldude832 Posted September 16, 2008 Share Posted September 16, 2008 second note make UNIX and Windows happy and use \r\n for any line breaks not just \r or \n Link to comment https://forums.phpfreaks.com/topic/124544-solved-mail-function-sending-email-to-both-sender-and-recipient/#findComment-643198 Share on other sites More sharing options...
scott_m Posted September 16, 2008 Author Share Posted September 16, 2008 removed "-f$theFrom" and all seems to be ok now thanks Link to comment https://forums.phpfreaks.com/topic/124544-solved-mail-function-sending-email-to-both-sender-and-recipient/#findComment-643236 Share on other sites More sharing options...
DarkWater Posted September 16, 2008 Share Posted September 16, 2008 Oh, and sorry, you WERE using mail() correctly. I was looking at the SendMail() function and wasn't paying attention. xD Link to comment https://forums.phpfreaks.com/topic/124544-solved-mail-function-sending-email-to-both-sender-and-recipient/#findComment-643241 Share on other sites More sharing options...
redarrow Posted September 16, 2008 Share Posted September 16, 2008 $headers .= "Reply-To: $theFrom\n"; this header was sending a email to u......... but u solved it buy deleting it well done....... Link to comment https://forums.phpfreaks.com/topic/124544-solved-mail-function-sending-email-to-both-sender-and-recipient/#findComment-643287 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.