Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I recently set up a home-server. And since my ISP quite annoyingly blocks outgoing port 25 I can't setup the SMTP properly. So I set it to relay via gmail(I don't send a lot of mails by this server anyhow, so it's no problem).

Now I have a Magento installation with contactform, if I use that(which uses the localhost SMTP) the from header field is fine with the correct name as well as the correct e-mail address.(note: this is not because of a reply-to header field, the from field really states the correct address)

I also created some e-mail accounts however with which I want to send mail through thunderbird. When I try to send a mail that way the From name is correct, but the e-mail address is the account I use for the relay. Here is an excerpt of my mail.log:

Mar 20 23:11:42 homeserver postfix/smtpd[12203]: connect from xxxx[ip address]
Mar 20 23:11:42 homeserver postfix/smtpd[12203]: setting up TLS connection from xxxx[ip address]
Mar 20 23:11:42 homeserver postfix/smtpd[12203]: Anonymous TLS connection established from xxxx[ip address]: TLSv1 with cipher AES256-SHA (256/256 bits)
Mar 20 23:11:42 homeserver postfix/smtpd[12203]: C5A4936E0228: client=xxxx[ip address], sasl_method=PLAIN, sasl_username=internalemail@domainnameiown.com
Mar 20 23:11:42 homeserver postfix/cleanup[12206]: C5A4936E0228: message-id=<4D867BA1.9080507@domainnameiown.com>
Mar 20 23:11:42 homeserver postfix/qmgr[11844]: C5A4936E0228: from=<internalemail@domainnameiown.com>, size=712, nrcpt=1 (queue active)
Mar 20 23:11:43 homeserver postfix/smtpd[12203]: disconnect from xxxx[ip address]
Mar 20 23:11:43 homeserver postfix/smtp[12207]: C5A4936E0228: to=<example@gmail.com>, relay=smtp.gmail.com[]:587, delay=1, delays=0.18/0/0.41/0.43, dsn=2.0.0, status=sent (250 2.0.0 OK 1300659106 u45sm1482760eeh.9)
Mar 20 23:11:43 homeserver postfix/qmgr[11844]: C5A4936E0228: removed

So when I would login to example@gmail.com now the from e-mail address is wrong. Is this a setting I got wrong on my homeserver, or can the client set this?

share|improve this question
How exactly is the from e-mail address wrong? I can't tell from what you've supplied so far. –  Jeremy Bouse Mar 20 '11 at 22:52
@Jeremy Bouse: well, say I use the account one@gmail.com as a relay. And two.com is on my server as a domain. When I send from my server as Info<info@two.com> now. The client recieves it as Info<one@gmail.com> –  teuneboon Mar 20 '11 at 23:47

2 Answers 2

up vote 2 down vote accepted

As far as I know, if you use Gmail's SMTP as a relay it rewrites the From address to the Gmail account. Also, any reply-to address is rewritten to the same Gmail account. They've done this for years.

I've run into the same thing when I tried setting Gmail as my relayhost in Postfix. This does not happen with other relays I've tried, so I believe it to be a Gmail thing. I assume Google does this to prevent systems marking the mail as spam since the original From cannot be verified easily.

For individual non-gmail adresses you could configure Gmail by verifying the address. See: http://mail.google.com/support/bin/answer.py?answer=22370

For all adresses in a domain you could configure the domain to use Google Apps, although I've not tried this. Unfortunately this won't help if you relay mail for a number of domains.

See this question for more discussion on this subject: SMTP relay through GMail overrides "from:" address with "[me]@gmail.com"

share|improve this answer

Postfix has a feature called "smtp_generic_maps"

You can create a generic maps file with

postmap /path/to/map/file

The map file looks like this

user@localhost user@remotehost

Then add

smtp_generic_maps = hash:/etc/postfix/generic

into main.cf

Mails from user@localhost will now be delivered as user@remotehost using SMTP

share|improve this answer
Thanks! this helped me. When I replaced my gmail relay account with another, it was still sending from previous gmail account. I first issued postmap and restarted postfix and then it worked!. –  user53864 Oct 24 '13 at 5:18

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.