1

Hello I'm using PHP built in php mail() and using this function s=to send emails :

function sendEmail($to,$subject,$message){
   $header = 'From: noreply@xxxxx.com' . "\r\n" .
   'MIME-Version: 1.0' . "\r\n" .
   'Content-type: text/html' . "\r\n" ;
   $retval = mail ($to,$subject,$message,$header);
   if( $retval == true ){
      return true;
   }
   else{
       return false;
   }
}

This function is sending emails but I do receive them not from the "From email" header I set : "noreply@xxxxx.com" but from my host server like this : xxx@host205.hostmonster.com

Why this is not working as I want?

Thanks

oussama kamal
  • 1,027
  • 2
  • 20
  • 44
  • Try `ini_set('sendmail_from', 'example@YourDomain.com');` – Jonathan Kuhn Oct 20 '14 at 19:34
  • 1
    @Termato just wondering, where in there you you see PHPMailer? I would assume from the `mail()` call, it is using the built in php `mail()` function. – Jonathan Kuhn Oct 20 '14 at 19:35
  • yes sorry built in php mail() – oussama kamal Oct 20 '14 at 19:37
  • 2
    Also, this stuff is usually covered in your hosting provider's help section. Such as this: https://my.hostmonster.com/hosting/help/206 For stuff related to a specific host, such as configuration, you are usually best off checking there first. – Jonathan Kuhn Oct 20 '14 at 19:39
  • @JonathanKuhn do you know if Hostmonter and BlueHost are owned by the same company, because both their sites look very similar: https://my.bluehost.com/cgi/help/206 - Edit - Looks like they are the same company, interesting: http://www.10-cheapwebhosting.com/BlueHost-vs-HostMonster.php – Termato Oct 20 '14 at 19:50
  • I just went to the site based on the email address you specified. – Jonathan Kuhn Oct 20 '14 at 20:11

1 Answers1

1

You want to use a properly formatted "From" statement as follows:

 $header = 'From: <noreply@xxxxx.com>' . "\r\n" .

or

 $header = 'From: "no reply" <noreply@xxxxx.com>' . "\r\n" .

and another possible approach could be this: problem with php mail 'From' header

Community
  • 1
  • 1
Termato
  • 1,556
  • 1
  • 16
  • 33