Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm on Ubuntu Server 12.04 and I managed to install & configure Exim4 following this guide.

I set my hostname to '' and my /etc/hosts looks like this:                           localhost                           multiformeingegno
IPv4 ADDRESS                    multiformeingegno
IPv6 ADDRESS                    multiformeingegno

I can send mails through PHP just fine. I have 2 questions.

  1. I'm on a VPS and my host is like, I'd like to hide this address from my sent mails! I can view it from the tag: Received: from ( [IPv4 ADDRESS]) Is there a way to only display '' as "received from"?

  2. On my VPS I host multiple sites. How can I change my hostname/fqdn (correct me if I'm using terms unproperly) according to the domain "in use"? For example I have a contact form in my website and another contact form in the other website How can I have "Return-path", "Received from", etc changing according to the website that's actually sending mails? Is this possible?

share|improve this question
up vote 0 down vote accepted
  1. That header is added by the MTA which receives the message from your server. It gets the hostname by doing a reverse lookup on the IP address you used to connect from. The only way to change this hostname is to get your hosting provider to change the PTR record for your IP address.
  2. I don't know specifically about Exim, but it's uncommon to have a mail server change its declared hostname based on the message being sent, so I doubt that you can do this.
  3. The Return-Path is determined by the From address, so this should happen automatically.
share|improve this answer

I have a VPS hosting multiple domains on Ubuntu 14.04 and wanted to make sure the email headers being sent only included the IP or the FQDN of the virtual host.

I first started with this guide on Linode. Afterwards I performed the following steps:

Create a file - /etc/exim4/mailhelo and using the syntax of produce something like:

Create a file - /etc/exim4/conf.d/01_custom_transport and insert add the following:

REMOTE_SMTP_HELO_DATA = ${lookup{$sender_address_domain}lsearch{/etc/exim4/mailhelo}{$value}{$primary_hostname}}

Edit the file - /etc/exim4/conf.d/30_exim4-config_remote_smtp and add the following to the end of the file:

headers_remove = "received"


service exim4 restart

Looking at the headers of a web form email, there is no evidence of my VPS host name. Don't forget to create a SPF record for the virtual host with your DNS provider.

share|improve this answer
  1. You cannot hide the address from the sent emails due to the reason described by mgorven: it's added by the mail server which receives the email, not by your mail server.
  2. You can configure exim to change its outbound name (i.e. the name used in EHLO/HELO), and if you have more than one external IP address, you can configure exim to change which outbound IP address it uses in the transport.

Sample transport:

  debug_print = "Transport: remote_smtp_forwarder for $local_part@$domain"
  driver = smtp
  max_rcpt = 10
  hosts_max_try = 2
  interface =
  helo_data = ""

In this example, the is NAT'd outbound and will connect to your mail server from (, and it will issue a "EHLO" to your mail server. I have mine hardcoded to a specific IP address, but you could also use a lookup to have it determine the interface and the helo_data if you wanted. It depends how much complexity you need.

share|improve this answer
And as far as having the correct Return-Path being set, you have to understand the difference between "envelope" From and "header" From. Header From is what you see in the email itself, what your mail client shows. The Envelope From is the actual email address that your mail server uses when it connects and issues the "MAIL FROM" command. Those two (header and envelope) do not have to be the same, and in many cases, they are not. So if you set the correct envelope sender address, the Return-Path will be correct for the person who receives the email. – Todd Lyons Jun 18 '12 at 18:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.