I have set up postfix on a server that has to send all output from root to R*****@gmail.com - But the problem is that when it sends mail it tries and sends to "root@rene-desktop" which I am notified via gmail:

"Your message was not delivered to the root@rene-desktop because the domain rene-desktop was not found. Check if there are spelling errors or excess spaces and try again."

I just want the following: Root ---------> My gmail. (Not root@rene-desktop)

What can the problem be?

Sudo nano main.cf
myhostname = localhost.localdomain
mydestination = localhost localhost.localdomain
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options =
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
compatibility_level = 2

sudo nano /var/log/mail.log
Jan 29 13:35:55 rene-desktop postfix/cleanup[1686]: F1E494016EB: message-id=<20190129123555.F1E494016EB@localhost.localdomain>
Jan 29 13:35:56 rene-desktop postfix/qmgr[1313]: F1E494016EB: from=<root@rene-desktop>, size=420, nrcpt=1 (queue active)
Jan 29 13:35:57 rene-desktop postfix/smtp[1690]: F1E494016EB: to=<root@rene-desktop>, relay=smtp.gmail.com[]:587, delay=1.7, delays=0.02/0.06/0.61/1, ds$
Jan 29 13:35:57 rene-desktop postfix/qmgr[1313]: F1E494016EB: removed

An email message with an unknown domain won't be accepted/routed by Gmail.

Furthermore, an email from root@ any domain won't be accepted either, but my memory might be betraying me.

If you need those emails accepted to gmail, you need to change/mask them to a valid domain in the Internet.

Those restrictions are not specific to the gmail service, since the 90s that email routing rules have been tightened up by email service operators to fight spam.

For rewriting your outgoing email address in postfix, you have to do:

Add to your main.cf file:

smtp_generic_maps = hash:/etc/postfix/generic

Now create a the /etc/postfix/generic file with the contents:

root@rene-desktop your_email@gmail.com

It is however not enough creating the generic file, you have to tokenize it for postfix to use it. Do then to create the generic.db file:

postmap /etc/postfix/generic

Now restart postfix and you should have that email mapping in place.

  • Yes I know ... But how do I change the setup in postfix so that it does not send to "Root@rene-desktop" but to my gmail "R********@gmail.com" I am well clear over it can't send to that mail ... – Rene Mortensen Jan 29 at 16:40
  • I don't know how to change it in the postfix reason I ask – Rene Mortensen Jan 29 at 16:41
  • Sorry, did not understand from the question you were aware of it. Added the steps to the answer. – Rui F Ribeiro Jan 29 at 19:25
  • 1
    I lacked these commands in my main.cf: alias_maps = hash:/etc/aliases, alias_database = hash:/etc/aliases, myorigin = /etc/mailname, inet_interfaces = loopback-only After I had added them it work :) – Rene Mortensen Jan 29 at 20:41
  • 1

Your Answer

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

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