homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Gold Sponsor 2015!
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

PHP Mail function
From field displays hosting provider subdomain

5+ Year Member

Msg#: 3126824 posted 11:40 am on Oct 19, 2006 (gmt 0)

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 :)



10+ Year Member

Msg#: 3126824 posted 12:21 pm on Oct 19, 2006 (gmt 0)

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();


5+ Year Member

Msg#: 3126824 posted 6:36 pm on Oct 19, 2006 (gmt 0)

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?


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

Msg#: 3126824 posted 10:31 pm on Oct 19, 2006 (gmt 0)

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved