Send an email from exim to another SMTP server strippping the local envelope

eximmasquerade

I manage a service that recently switched to AWS/EC2 but we have several IP addresses with great email reputation that we'd like to keep sending the email through. We've set up exim to be a satellite on the EC2 instances so that email sent with sendmail locally on that machine will be sent through our existing SMTP server outside of AWS. This works well.

The only problem is that our emails no have the AWS/EC2 hostnames in the message envelopes. This causes problems with people who report the emails as spam which get sent to AWS. For instance, here are example headers I want to not exist:

    Received: from ec2-XX-XX-XXX-XXX.compute-1.amazonaws.com ([XX.XX.XXX.XXX]:XXXXX helo=www2.server.com)
        by server.com with esmtpsa (TLSv1:DHE-RSA-AES128-SHA:128
        (Exim 4.80.1)
        (envelope-from <bounce@server.com>)
        id XXXXXX-0003Sm-Ex
        for user@host.com; Wed, 09 Apr 2014 11:52:43 -0400
    Received: from www-data by www2.server.com with local (Exim 4.80)
        (envelope-from <bounce@server.com>)
        id XXXXXX-0003Kv-9F
        for user@host.com; Wed, 09 Apr 2014 11:52:43 -0400

I don't mind the 2nd Received header, but I need to remove the first one. Is there anyway to set that up?

Update: it seems that the headers_remove: Received is the right directive to use. But I'm not totally sure where to put it in the config file (actually using WHM/CPanel to manage this server).

Best Answer

It was the headers_remove: Received option that I was looking for. At first I tried it on the satellite server, but of course that didn't work because these particular Received headers weren't added until it was actually received by the smart-host server. So it needed to belong on the smart-host's exim configuration.

This directive needs to put it in a router, but this was complicated by the fact that this server was managed by CPane/WHM which locks portions of the exim configuration file. The solution was to create a new router that ran before the predefined routers. This router was a copy of the one I wanted to modify but with this headers_remove option added. Saving and restarting and everything works beautifully.

Related Topic