Wednesday, February 17, 2016

How to set the default return-path and sender values in exim

Migrating a website to a new hosting can be sometimes a little bit problematic. One common problem related to VPS email management is when you try to send messages from PHP with the Exim Mail Transfer Protocol.

Perhaps you have found that in the source of your emails the Return-path and Sender address values are set incorrectly, using the value of your hosting username instead of the real email address, something like:

Return-path: <hosting-username@your-domain.com>
Sender: <hosting-username@your-domain.com>

Forcing these settings in the headers of your PHP source code might not work, even when forcing the 5th parameter in the mail function, or adding it in the sendmail parameter of you php.ini.

To solve it you only need to:

1) Access to your VPS by SSH

2) Edit the file: /etc/exim/exim.conf

3) Look for the REWRITE CONFIGURATION section (you can find it in Vi typing /f and entering 'rewrite conf'

4) Create a line under 'begin rewrite' and enter something like this:


hosting-username@your-domain  info@your-domain.com

5) Save it and restart your exim service, typing 'service exim restart'.

If everything went fine your email headings should be set perfectly.