4

I am using Amazon SES which in postfix master.cf looks like this....

aws-email  unix  -       n       n       -       -       pipe
  flags=R user=dhiller argv=/usr/bin/perl -I/opt/amazon/ses /opt/amazon/ses/ses-
send-email.pl -r --verbose -k /opt/amazon/ses/aws_credentials.conf -e https://em
ail.us-east-1.amazonaws.com -f support@alvazan.com ${recipient}

I was hoping the support@alvazan.com would override the from address but that didn't seem to work when sending from wordpress though it works if I use command line send.

Anyone know how to configure postfix to change all emails received to have a From address before calling that above amazon perl script so my from addresses are correct?

thanks, Dean

Steffen Opel
  • 5,560
  • 35
  • 55
Dean Hiller
  • 841
  • 4
  • 14
  • 31

1 Answers1

5

I believe the solution is via the canonical(5) mapping facility, which describes address cleanups to be performed with the cleanup(8) daemon:

   The optional canonical(5) table specifies an address mapping
   for local and non-local addresses. The mapping is used by the
   cleanup(8) daemon, before mail is stored into the queue.  The
   address mapping is recursive.
   ...
   Typically, one would use the canonical(5) table to replace
   login names by Firstname.Lastname, or to clean up addresses
   produced by legacy mail systems.

This address cleaning can be performed both to local submissions (/usr/sbin/sendmail) and remote submissions (via SMTP) -- if Wordpress sends mail via SMTP. you might need to add your Wordpress hostname to local_header_rewrite_clients.

You provide a plain text table (typically /etc/postfix/canonical) to the postmap(1) command to build the indexed database. If the From: from Wordpress is always the same (wordpress@alvazan.com, for example), then the entry would be:

wordpress@alvazan.com support@alvazan.com

If the From: from Wordpress changes, but the domain is always the same, you could use:

@alvazan.com support@alvazan.com

If the From: really could be just about anything and you always want support@alvazan.com in the From: headers, you could use the regex support. I'm a little leery about this, but it's an option:

/./ support@alvazan.com

You should set the canonical_classes variable to envelope_sender, header_sender. (By default, it also includes envelope_recipient and header_recipient; it might not hurt to leave it alone, but (especially with that greedy regex option) could be catastrophic. It depends upon how this specific server is used.)

I recommend testing late at night and make sure you test mail coming in and out of the system after making all changes. And don't forget to keep your configs under some kind of source control. (But you knew all that.)

sarnold
  • 1,211
  • 7
  • 9
  • Obvious in hindsight, but if using the regex solution, Postfix must be configured with `canonical_maps = regexp:/etc/postfix/canonical`. :) – Søren Løvborg Mar 26 '14 at 13:48