Set email headers so bounced emails go to a specific address

I just figured this out myself in exim4 after a lot of reading about exim configuration.

First, you want your app to add the following header:

Return-Path: <bounced@yourdomain.com>

Works with or without brackets. Exim will add brackets in the end either way.

Second, this was the hard part. Exim always wanted to override my Return-Path: address with the unix user who sent it. You can use /etc/email-addresses in Ubuntu to set a static email for the user of your web app, but this still ignores the Return-Path header. Here is how I modified my exim config to respect the Return-Path from the web app:

In the main config area add:

return_path_remove = false

In the appropriate router config (e.g. dnslookup):

dnslookup:
  # ...
  errors_to = ${if def:h_return-path: {${address:$h_return-path:}} fail}
  headers_remove = return-path
  no_more

Now exim should copy the Return-Path header address at the envelope-level and delete the original Return-Path header.

I tried lots of other configuration directives and this is the only way that actually worked for me.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)