Postfix mydestination question

Having looked at the Postfix documentation, it looks like the standard practice for Postfix configuration is to have your mydestination entry point to your localhost:

http://www.postfix.org/postconf.5.html#mydestination

Mine in my main.cf looks like this (domain names faked so that if I have a big hole in the server I'm not pointing spammers at my server):

#this resolves to the mail server
myhostname = liXX-XX.members.linode.com 
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

# this is a debian system, and this file has an entry liXX-XX.members.linode.com
myorigin = /etc/mailname 
mydestination = liXX-XX.members.linode.com, localhost
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

I have a few virtual domains & mailboxes that PHP is sending email to users from, and I've got them listed as follows:

virtual_mailbox_domains = example.net, example.com
virtual_mailbox_base = /mail
virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtualmailboxes.cf
virtual_minimum_uid = 5000
virtual_uid_maps = static:5000
virtual_gid_maps = static:100
virtual_alias_maps = mysql:/etc/postfix/mysql/virtualaliases.cf

My question relates to the email headers that are sent with the email from my PHP scripts. In the header, as expected based on the above settings, a few of the headers are as follows:

Return-Path: <www-data@lixx-xx.members.linode.com>Received: by liXX-XX.members.linode.com (Postfix, from userid 33)</www-data@lixx-xx.members.linode.com> 

So, it would be great to be able to have the return-path be the same email account that is sending the email via PHP (specified in the email from, reply-to headers) for each virtual domain (i.e. webmaster@example.com, listmaster@eample.net, etc) rather than the default PHP user with the full path to the server (the linode dns path). But since I can't specify virtual domains in mydestination, is this even possible?

Second question, the Received field indicates the hostname of the server. Again, would be great to have this be the same domain as the virtual domain that sends the email, rather than the linode domain name… again, is this possible with virtual domains?

Thanks for any info,

Paul

5 Replies

@pmmenneg:

it would be great to be able to have the return-path be the same email account that is sending the email via PHP (specified in the email from, reply-to headers) for each virtual domain (i.e. webmaster@example.com, listmaster@eample.net, etc) rather than the default PHP user with the full path to the server (the linode dns path).

Check out the php mail docs – you can set the From: header either individually in the additional_headers, or globally via php.ini.

@pmmenneg:

Second question, the Received field indicates the hostname of the server. Again, would be great to have this be the same domain as the virtual domain that sends the email, rather than the linode domain name… again, is this possible with virtual domains?
Easy enough on Exim, but not sure of the best way on Postfix. Undoubtedly someone else will pipe up. ;)

I have set the From, Reply-To in the additional headers… Return-Path is the one I'd like to 'clean up' if possible, but thought that was likely more of a Postfix issue than PHP. I've tried setting it from PHP and no luck.

Fair enough. My assumption had been that you weren't setting anything in mail(), and hence that your MTA was then cleaning up the headers (inserting defaults) in their absence. Presumably you put \r\n, or similar between the headers, and have tried the -f option also.

But yes, you are probably correct in thinking that it's a Postfix/MTA issue.

Figured it out I believe. Passing Postfix the sender email via the -f parameter from the PHP mail() function changed the sender envelope so that the email now appears to originate from the actual sender.

paul

@pmmenneg:

Figured it out I believe. Passing Postfix the sender email via the -f parameter from the PHP mail() function changed the sender envelope so that the email now appears to originate from the actual sender.

paul

Actually, this just solved the issue related to the destination, but not the other 'issue' related to the mail server domain from Postfix's myhostname setting.

Anyone aware of a way to have the Postfix MTA domain set to your virtual domain (say mx.example.com, mx.example.net, etc all of which would resolve to the server and would be a FQDN) rather than having it hardcoded to a single 'universal' domain name?

Thanks,

Paul

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct