Using X-Script-PHP for non-nobody mail senders

Silent Ninja

Well-Known Member
Apr 18, 2006
196
0
166
Buenos Aires, Argentina
I have a customer that uses a mail form in PHP to send e-mails as a different e-mail account (from address changed).

He used the header "Sender" with his own domain to show "in behalf of <domain>", but my cPanel server seems to be removing that line from the headers, and writing my hostname instead of his own domain.

On the linen X-PHP-Script and X-Source-Dir the domain is shown correctly, but it seems that GMail and Outlook reads the line saying X-Get-Message-Sender-Via or X-AntiAbuse: Sender Address Domain (not sure which one) which shows my hostname.

Is there some tweak to make my cPanel server show the originating domain from X-PHP-Script instead of my hostname?
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello :)

You can try enabling the following option under the "Mail" tab in "WHM Home » Service Configuration » Exim Configuration Manager":

"Set SMTP Sender: headers"

Per it's description:

(-f flag passed to sendmail) This will create “On behalf of” notices in Microsoft® Outlook, but it may also help track abuse of the mail system since recipients will see the SMTP login used to send each message.

Keep in mind that you may need to also configure the script to utilize SMTP Authentication for sending email.

Thank you.
 

Silent Ninja

Well-Known Member
Apr 18, 2006
196
0
166
Buenos Aires, Argentina
Hmm, I'm not sure if that's want I'm looking for. It seems that option adds the Sender automatically, and I won't use SMTP Auth in this case it would be unpractical.

I want to be able to EDIT the Sender variable using the mail function headers, or using the fifth parameter. Here's the function I want to use:

mail('[email protected]', 'testing', 'content', "From: [email protected]\r\nSender:webmaster@<mydomain>\r\n", '-fwebmaster@<mydomain>');

cPanel seems to be removing the Sender header and the fifth parameter as well; thus the email is marked as spam because I'm obviously not the owner of example.com.

I want to be able to set the Sender header in this server, since it's a dedicated server, and have it shown "in behalf of <mydomain>" instead of <myhostname>
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
The default behavior when sending email through PHP is to use the cPanel username and hostname of the server to construct the envelope-sender address. Most applications that call the Exim/Sendmail binary will pass the -f switch along with the proper email address to keep that from happening. If you can configure the mailer to use SMTP and authenticate with SMTP AUTH, this will set the correct "Return-Path" in the headers. The other option is to make sure that the application is using the 5th argument to the PHP mail() function to send the '-f' switch to sendmail so that it sets the correct "Return-Path". Keep in mind that your results may vary depending on which mail server is accepting the email.

Thank you.