BoarderLine Posted July 20, 2010 Share Posted July 20, 2010 I am using the following code to try and send an email. $to = "[email protected]"; $subject = 'Request'; $message = "message content here"; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= "From: [email protected]\r\nReply-To: [email protected]"; //send the email mail( $to, $subject, $message, $headers ); The email is sending alright however in the sender and reply-to fields on the received email are showing:- SENDER: [email protected] REPLY-TO: ''@server.url.co.nz I thought that these two email addresses were already set in the code $headers .= "From: [email protected]\r\nReply-To: [email protected]"; Obviously I am missing something here.... Do I need to change something in php.ini or in the sendmail options ?? Can anyone please point me in the right direction here. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/208340-php-mail-problem/ Share on other sites More sharing options...
waynew Posted July 20, 2010 Share Posted July 20, 2010 Hey buddy, you could try using my function if you want. It's pretty simple stuff and I always use it on projects: function simple_mail($from, $to, $subj, $msg, $charset="UTF-8", $extraheaders=""){ $headers = "From: {$from}\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: text/html; charset=\"$charset\"\n"; $headers .= "Content-Transfer-Encoding: 7bit\n"; $headers .= $extraheaders; $headers .= "\n"; $msg = $msg."\n\nThank You"; @ $ret = mail ($to, $subj, $msg, $headers, "-f$from"); return $ret; } Quote Link to comment https://forums.phpfreaks.com/topic/208340-php-mail-problem/#findComment-1088802 Share on other sites More sharing options...
BoarderLine Posted July 20, 2010 Author Share Posted July 20, 2010 Thanks Wayne, using this method got things a little better. Still the following issues (F.Y.O. using Mozilla Thunderbird client):- FROM is now displaying as [email protected] (thanks) Although below that I have SENDER: [email protected] (which I dont want to displayed) and REPLY-TO:[email protected] (which needs to be [email protected]) Any ideas??? Quote Link to comment https://forums.phpfreaks.com/topic/208340-php-mail-problem/#findComment-1088832 Share on other sites More sharing options...
waynew Posted July 20, 2010 Share Posted July 20, 2010 Are you using simple_mail($from, $to, $subj, like simple_mail("[email protected]", "[email protected], "Hi", ?? Quote Link to comment https://forums.phpfreaks.com/topic/208340-php-mail-problem/#findComment-1088839 Share on other sites More sharing options...
BoarderLine Posted July 20, 2010 Author Share Posted July 20, 2010 yes Quote Link to comment https://forums.phpfreaks.com/topic/208340-php-mail-problem/#findComment-1088847 Share on other sites More sharing options...
BoarderLine Posted July 20, 2010 Author Share Posted July 20, 2010 I used this: simple_mail("[email protected]", "[email protected]", "subject", "message"); Quote Link to comment https://forums.phpfreaks.com/topic/208340-php-mail-problem/#findComment-1088849 Share on other sites More sharing options...
waynew Posted July 20, 2010 Share Posted July 20, 2010 Hmm. That function always works for me. Maybe its your server or your email client. Quote Link to comment https://forums.phpfreaks.com/topic/208340-php-mail-problem/#findComment-1088852 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.