Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

Is this possible?

The reason I ask this is because Gmail keeps attaching the 'via' field in the email messages originated from one of my sites that resides in a server with the hostname of a whole different domain.

Besides moving this site to its own server, is there any other way to get rid of the 'via' field? After researching for a bit, I find the only solution is to give the server the hostname of the domain that sends the email. But it would be bad to remove the current hostname. Here goes the question.

Is this possible for Linux to have multiple hostnames?

share|improve this question
It's normally buried in the server MTA config (i.e. which email domain to use) and by default is often the FQ hostname of the server running your website. But you haven't told us anything about your server. Is it hosted? your own VPS...what? – Matt Oct 31 '12 at 1:10
Please reword your question. Apache has nothing to do with email and there is no reason to even mention it. If you don't understand what you're asking you can't really expect good answers. – John Gardeniers Oct 31 '12 at 2:01
Thank you both for the comments and interests in my question. As John pointed out, I didn't ask it quite the right way but was lucky enough to get an answer anyway. Thanks everyone again! – Oct 31 '12 at 2:50
up vote 3 down vote accepted

Gmail displays the "via" domain when it thinks that the mail has not been sent by an authorised MTA for that domain. To prevent this being displayed you need to configure SPF and DKIM to authorise your mail server for that domain.

Edit: From the page you linked:

In cases where there was any domain match between the visible from: and the return path, either the exact domain or a subdomain, there was no “via” displayed, even if authentication failed.

Only when there is a domain mis-match and failing authentication is a via displayed.

So you need to make your Return-Path use the same domain as the From header. The Return-Path is determined by the envelope from address specified by the originating SMTP client.

share|improve this answer
Thanks for the tips but I have tried it all. SPF and DKIM only seem to help identify your messages as legal ones (NOT spam) so they aren't caught in the spam folder. But it still displays a 'via' field. Check this: – Oct 31 '12 at 0:46 Edited answer. – mgorven Oct 31 '12 at 1:01
That's the answer! Thank you! I didn't quite follow what a return path was....For PHP mail(), just add a 5th parameter as '' for to be the Return-Path email - – Oct 31 '12 at 2:01

In /etc/hosts you can define multiple hostname for the machine like: host1.domainl host2.domain2 host1 host2

The machine will answer to all these hostnames on IP

Obs: you can do the same for or any other IP you want your machine to answer too. (multiple IP too if the machine has multiple IP assigned).

share|improve this answer
Thanks that seems to be it. However I'm using WHM/cPanel on my host and it keeps updating /etc/hosts with a single hostname. And there doesn't seem to be any way to add multiple hostnames via WHM/cPanel......what do I do? – Oct 31 '12 at 1:31
Sorry, no idea, I never worked with cPanel... – laurent Oct 31 '12 at 2:33

You can add a servername in the virtual hosts.

<VirtualHost *:80>
DocumentRoot /www/example1
share|improve this answer
Is that the same as a hostname? I'm not an expert of Linux but I suppose hostname is more a system thing rather than an Apache thing? Probably in /etc/hosts or something? – Oct 30 '12 at 13:51
Had you read the question you would know that the OP is asking with respect to email, not web hosting. Admittedly, it is a very confused and convoluted question. – John Gardeniers Oct 31 '12 at 1:59

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.