I have a mail server all set up and running on ubuntu 14.04 with Postfix / Dovecot for the domain "postfixserver.com".

A second domain "googleapps.com" is running on google apps.

user@googleapps.com emails are forwarded from google apps to user@postfixserver.com.

When user@postfixserver.com replies to an email addressed to user@googleapps.com I would like postfix to send the email out as being from user@googleapps.com.

Is there any way to achieve this without having to rely on the email client. So for instance on an iPhone I would like to only setup one account user@postfixserver.com but being able to reply to emails sent to user@googleapps.com keeping the correct from address.

  • Google...first result: postfix.org/ADDRESS_REWRITING_README.html – flashbang Dec 4 '14 at 15:13
  • Thank you for this but still can't get my head around it. I am assuming that from the link above what I need to look at is the "Generic mapping for outgoing SMTP email". If that is the case editing: /etc/postfix/main.cf by adding smtp_generic_maps = hash:/etc/postfix/generic and then inside my generic user@googleapps.com user@postfixserver.com? I am also assuming I will need an spf record setup on the googleapps domain to allow the other server to send emails using that address? – user257084 Dec 4 '14 at 15:34
  • Sounds like you've got it! – flashbang Dec 4 '14 at 15:40
  • Just tested this and it's not working. From a third domain I send an email to the googleapps domain than gets automatically forwarded to the postfixdomain. When I reply from the postfix domain the third domain gets the reply with the from address from the postfix domain. Any ideas? – user257084 Dec 4 '14 at 16:59
  • Oops, my mistake I had to invert the addresses in the generic db. Still in the header of the email I can see the postfix email address. Do you know if there is any way to hide that? – user257084 Dec 4 '14 at 17:07

TLDR: No. You can't. It isn't MTA job.

Suppose external address send email to gapps domain. Here the full email looks like

From: alice@external.example.com
To: user@GAPPS.example.net
Subject: Hello World

This is 'Hello world' version of email

Because user@GAPPS.example.net forwarded it to postfix.example.org then user@postfix.example.org get and read the email.

Now user@postfix.example.org wants to reply it. IPhone compose the emails and sent to postfix. Here the example reply which postfix would see from user@postfix.example.org

From: user@postfix.example.org
To: alice@external.example.com
Subject: Re: Hello World

On 7 Mar 2014, at 21.21, Someone <alice@external.example.com> wrote: 
> This is 'Hello world' version of email

Okay hello world. Your email was received :)

You can see that in the second email there is no trace that alice@external.example.com have sent email to GAPPS.example.net.

  • Unfortunately for me the above makes perfect sense. Is there anything that can be done at the time the email gets delivered to postfix or at the time it's forwarded from the google apps? Or any other solution that would not involve the mail client? – user257084 Dec 5 '14 at 8:52
  • I think that's not possible. You can't control how mail client compose the message for you – masegaloeh Dec 5 '14 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy