Jump to content

php mail problem


BoarderLine

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/208340-php-mail-problem/
Share on other sites

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;
   }

Link to comment
https://forums.phpfreaks.com/topic/208340-php-mail-problem/#findComment-1088802
Share on other sites

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???

 

 

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/208340-php-mail-problem/#findComment-1088832
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.