Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP Mail function

From field displays hosting provider subdomain



11:40 am on Oct 19, 2006 (gmt 0)

5+ Year Member

I am experiencing unexpected results when using the PHP mail function. I am sending the email with the header:
$mailheader = 'From: Sou Desade' . "\r\n" .
'Reply-To: address@email.co.uk' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

I also tried it without the extra 'X-Mailer: PHP/' . phpversion(), not sure why these are necessary at all. But the result is the same.

When the email comes through it says, in the 'from' field: "Sou@subdomain.hostingprovider.com; Desade@subdomain.hostingprovider.com"

I substituted subdomain.hostingprovider for the real address for the purposes of this post. The subdomain showed isn't even mine, but for the provider's account manager. I am new to PHP, do you know how I can get it to show "Sou Desade" in the from field? I tried 'From: "Sou Desade"' with the " signs, but it just showed up as "Sou Desade"@subdomain.hostingprovider.com

I contacted the provider in case it was an issue with the settings of the server but they said the issue was with the script and didn't offer much more help than that.

Any ideas? If so, thanks a lot :)


12:21 pm on Oct 19, 2006 (gmt 0)

10+ Year Member

bugsquish, Welcome to Webmaster World!

For the From header field you must also supply an email address like in the reply-to field. You can add your name if you wish, but an email address is required.
Use something like:

$mailheader = 'From: "Sou Desade" <address@email.co.uk>' . "\r\n" .
'Reply-To: address@email.co.uk' . "\r\n" .
'X-Mailer: PHP/' . phpversion();


6:36 pm on Oct 19, 2006 (gmt 0)

5+ Year Member

Hey thanks for the warm welcome and the words of wisdom! :)
Would you mind also telling me something else? Do you know what the 'X-Mailer: PHP/' . phpversion() does? Is it something to do with the spam filters?


10:31 pm on Oct 19, 2006 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Welcome to WebmasterWorld bugsquish (i like that nick ;)),

I would actually remove that line. All it does is put your version # of php in there, I have never been a fan of adding extra headers that don't do anything, though I have had this in some of my mail scripts when I needed to do some things.

also the line is not properly terminated anyway, it should look like this

$mailheader = 'From: "Sou Desade" <address@email.co.uk>' . "\r\n" .
'Reply-To: address@email.co.uk' . "\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n";

each line in the header needs to end in \r\n


Featured Threads

Hot Threads This Week

Hot Threads This Month