Forum Moderators: coopster

Message Too Old, No Replies

email headers in PHP

change who we're sending From:

         

bwstyle

4:09 pm on Nov 22, 2006 (gmt 0)

10+ Year Member



I change the email headers within PHP to say they're from me@mysite.com however in /var/log/maillog I see they're sent from root@mysite.com. I feel like this is responsible for our email getting blocked on other mail systems.

Am I not setting From: correctly?

ahmedtheking

5:22 pm on Nov 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's also good to spec Reply-To and Organization. But when you do from, don't just do an email address, do the name too:

Company Name <companysemail@theirsite.bool>

FalseDawn

5:22 pm on Nov 22, 2006 (gmt 0)

10+ Year Member



Post your code and let's take a look.

jatar_k

6:58 pm on Nov 22, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try setting

From
Reply-To
Return-Path

one of these will override the default server address

bwstyle

5:16 pm on Nov 27, 2006 (gmt 0)

10+ Year Member



I have set the Reply-To, From, and Return-Path. After the mail is sent, I can see the Return-Path has been changed to root@mysite.com and Old-Return-Path is now set to my original Return-Path intended value.

It sounds like the mail server is rewriting this? Or is it apache?

coopster

9:52 pm on Nov 27, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It is likely the sendmail utility. Have a look at the -f switch. You can set it up at the server level or during runtime. mail [php.net]

bwstyle

9:51 pm on Nov 28, 2006 (gmt 0)

10+ Year Member



I think I got it, thank you so much!

I had to use -fme@mysite.com as an additional mail() parameter in PHP and I had to add root to /etc/mail/trusted-users.

coopster

3:51 pm on Nov 29, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You got it, nice work. I commend your resourcefulness.