Question

I just installed ssmtp to send email with LAMP on Ubuntu.

And a simple script like this:

     <?php

     $additional_headers = 'From: someone@testing.com' . "\r\n";
     $res = mail('myemail@gmail.com','test','test body', $additional_headers);

     var_dump($res);

     ?>

I received the email but the sender name will put as "nobody" , so it is using the user name "nobody"? How can I change it? I'm new in Ubuntu...

Thanks.

Was it helpful?

Solution

Try changing your "Extra Headers" to also include a 'Reply-to' header EG:

$additional_headers = 'From: someone@testing.com' . "\r\n" .
'Reply-To: someone@testing.com' . "\r\n";

The way you have it SHOULD work, according to the documentation, but distance can vary depending on which MTA (Mail Transport Agent) your using.

The doc page is here : http://php.net/manual/en/function.mail.php

Additional:

Be aware, that in a lot of mail systems, you need to provide a valid DNS address too. On my mail server running ubuntu, if I give the from header as a domain that cannot be looked up using a valid DNS, the recipient address will appear blank.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top