Email Header Stuff. PHP return path is wrong

My other thread I edited the first post and went to moderation for editing the post after a few weeks and has been released but now its too bloated with potentially confusing old stuff which while relevant in some way would just server to just confuses people.

I have done a full reinstall on Centos 6.5 this time from Ubuntu 14.04, email is working better this time through Virtualmin, last time something had issues with default headers I have since learned about.

Although something still isn’t totally seem I think, with the headers with return path when using PHP, which doesn’t seem normal to me but I have seen another forum with the exact same thing I browse regularly.

Webmin itself seems to send the correct header information from the ‘Read User Mail’ module in the users mailbox for ‘Return-Path’ as seen in the code below.

From - Tue Jul 08 13:18:01 2014 X-Account-Key: account1 X-UIDL: GmailId14714682a67b5f31 X-Mozilla-Status: 0001 X-Mozilla-Status2: 00000000 X-Mozilla-Keys: Delivered-To: drguild@gmail.com Received: by 10.229.155.199 with SMTP id t7csp512098qcw; Mon, 7 Jul 2014 22:17:58 -0700 (PDT) X-Received: by 10.66.152.17 with SMTP id uu17mr19400092pab.13.1404796677909; Mon, 07 Jul 2014 22:17:57 -0700 (PDT) Return-Path: Received: from 110-175-205-112.static.tpgi.com.au (110-175-205-112.static.tpgi.com.au. [110.175.205.112]) by mx.google.com with ESMTP id gu3si42583522pbb.232.2014.07.07.22.17.55 for ; Mon, 07 Jul 2014 22:17:56 -0700 (PDT) Received-SPF: none (google.com: drguild@drguild.noip.me does not designate permitted sender hosts) client-ip=110.175.205.112; Authentication-Results: mx.google.com; spf=neutral (google.com: drguild@drguild.noip.me does not designate permitted sender hosts) smtp.mail=drguild@drguild.noip.me Received: by 110-175-205-112.static.tpgi.com.au (Postfix, from userid 0) id 3389F20174B; Tue, 8 Jul 2014 13:18:15 +0800 (WST) From: drguild@drguild.noip.me Subject: Webmin, read user mail - test To: drguild@gmail.com Message-Id: <1404796695.17398@drguild.noip.me> X-Originating-IP: 192.168.1.16 X-Mailer: Webmin 1.690 Date: Tue, 08 Jul 2014 13:18:15 +0800 (WST) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="bound1404796695"

This is a multi-part message in MIME format.

–bound1404796695
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Composing and typing a message in ‘Webmin’ under ‘Read User Mail’

–bound1404796695–

But from a PHP page on the server which all these tests were done using this php code, test code directly below.

<?php ini_set( 'display_errors', 1 ); error_reporting( E_ALL ); $from = "drguild@drguild.noip.me"; $to = "drguild@gmail.com"; $subject = "PHP Mail Test script"; $message = "This is a test to check the PHP Mail functionality"; $headers = "From:" . $from; mail($to,$subject,$message, $headers); echo "Test email sent"; ?>

Its outputting this return path:
(doesn’t matter if its this code or wordpress its the same Return-Path as I also tested wordpress)

Return-Path:

My ISP TPG strips it down to ‘drguild@tpgi.com.au’, gmail shows the full return path.

As mentioned above in Webmin ‘Read User Mail’ sending a message shows a proper return path as you saw above.

Also google is saying I don’t permit designated senders which is a separate issue I’m not worried about at this stage and have been told on another forum asking questions about these headers is due to the config on noip’s side which is out of my control unless I upgrade to a enhanced account.

So something still needs configuring from the virtualmin default install with PHP sending headers it seems.

From my email receiving end I get headers from PHP of:

From - Mon Jul 07 14:27:02 2014
X-Account-Key: account1
X-UIDL: GmailId1470f80fc022a869
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
X-Mozilla-Keys:
Delivered-To: drguild@gmail.com
Received: by 10.229.155.199 with SMTP id t7csp437778qcw;
Sun, 6 Jul 2014 23:26:58 -0700 (PDT)
X-Received: by 10.68.189.137 with SMTP id gi9mr17160506pbc.79.1404714417646;
Sun, 06 Jul 2014 23:26:57 -0700 (PDT)
Return-Path: drguild@110-175-205-112.static.tpgi.com.au
Received: from 110-175-205-112.static.tpgi.com.au (110-175-205-112.static.tpgi.com.au. [110.175.205.112])
by mx.google.com with ESMTP id df8si4489613pdb.455.2014.07.06.23.26.56
for drguild@gmail.com;
Sun, 06 Jul 2014 23:26:57 -0700 (PDT)
Received-SPF: none (google.com: drguild@110-175-205-112.static.tpgi.com.au does not designate permitted sender hosts) client-ip=110.175.205.112;
Authentication-Results: mx.google.com;
spf=neutral (google.com: drguild@110-175-205-112.static.tpgi.com.au does not designate permitted sender hosts) smtp.mail=drguild@110-175-205-112.static.tpgi.com.au
Received: by 110-175-205-112.static.tpgi.com.au (Postfix, from userid 502)
id AB80A201748; Mon, 7 Jul 2014 14:27:16 +0800 (WST)
To: drguild@gmail.com
Subject: drguild - PHP Mail Test script
X-PHP-Originating-Script: 502:testmail.php
From:drguild@drguild.noip.me
Message-Id: 20140707062716.AB80A201748@110-175-205-112.static.tpgi.com.au
Date: Mon, 7 Jul 2014 14:27:16 +0800 (WST)

If you can receive this then PHP is sending mail from web scripts aka .php pages. - drguild

From the maillog, I can see differences in how the headers are sent and from Webmin as mentioned appears fine but in the log you can see the PHP headers from ‘from=’ are different than what webmins ‘Read User Mail’ is sending.

Webmin "Read User Mail’ module:

Jul 8 13:44:36 server postfix/pickup[14986]: E11A5201753: uid=0 from=drguild@drguild.noip.me
Jul 8 13:44:36 server postfix/cleanup[18322]: E11A5201753: message-id=1404798276.18314@drguild.noip.me
Jul 8 13:44:36 server postfix/qmgr[17306]: E11A5201753: from=drguild@drguild.noip.me, size=598, nrcpt=1 (queue active)
Jul 8 13:44:39 server postfix/smtp[18324]: connect to gmail-smtp-in.l.google.com[2607:f8b0:400e:c02::1a]:25: Network is unreachable
Jul 8 13:44:42 server postfix/smtp[18324]: E11A5201753: to=drguild@gmail.com, relay=gmail-smtp-in.l.google.com[74.125.129.26]:25, delay=5.4, delays=0.09/0.01/2.8/2.5, dsn=2.0.0, status=sent (250 2.0.0 OK 1404798259 bf15si5652045pdb.194 - gsmtp)
Jul 8 13:44:42 server postfix/qmgr[17306]: E11A5201753: removed

PHP script:

Jul 8 13:47:42 server postfix/pickup[14986]: BC6F6201753: uid=506 from= Jul 8 13:47:42 server postfix/cleanup[18469]: BC6F6201753: message-id=<20140708054742.BC6F6201753@110-175-205-112.static.tpgi.com.au> Jul 8 13:47:42 server postfix/qmgr[17306]: BC6F6201753: from=, size=436, nrcpt=1 (queue active) Jul 8 13:47:42 server postfix/smtp[18471]: connect to gmail-smtp-in.l.google.com[2607:f8b0:400e:c02::1a]:25: Network is unreachable Jul 8 13:47:45 server postfix/smtp[18471]: BC6F6201753: to=, relay=gmail-smtp-in.l.google.com[74.125.129.26]:25, delay=2.4, delays=0.13/0.01/0.69/1.6, dsn=2.0.0, status=sent (250 2.0.0 OK 1404798442 da4si42642340pbb.222 - gsmtp) Jul 8 13:47:45 server postfix/qmgr[17306]: BC6F6201753: removed

Please note this was a fresh install of Centos 6.5 then a fresh install of virtualmin I haven’t manually edited anything and all apart from changing the postfix ‘Internet hostname of this mail system’ to match my external static ip hostname, I’ve done is created a few domains using virtiualmins GUI for testing letting it auto populate values.

Just posting back, lots of spelling errors etc in that post and to fix it would mean resending it to moderation to be approved again being a first post and the moderation team have probably had enough of my edits and posts for a while.

Anyway I seem to have figured out the solution from stumbling on a thread here and doing more google.

Canonical Mapping

I enabled and setup the file hashes and started testing once the file was populated and headers are being rewitten properly now.

I know there’s descriptions around in virtualmin about using this for this purpose but I wasn’t sure and didn’t really want to play around too much as the file wasn’t setup automatically and wasn’t sure what I needed to do to get that done and there’s very little descriptive documentation on what canonical mapping actually did in virtualmin and on the website I checked and searched for hours.

I have seen a few instances on here about this mapping and suggest because I just spent 2-3 weeks on it getting frustrated etc that there is documentation and a way to virtualmin to click a button and have it check addresses and enable it automatically if needed.

This would solve soo many issues for us home users using the GPL version who are running multiple virtual domains though nat on our isp’s etc

This topic can be marked as solved now and I hope that virtualmin can be improved so the amount of frustrating I went through doesn’t to someone else.

Having made this post if you use a sub server mail gets sent from the parent server even if its a totally different domain and doesn’t seem a way to avoid that unless you make each separate domain a top level server.