0

This specific Linux CentOS server is entirely in-house on the LAN. It is used for development and testing. With postfix, I was able to configure it to send e-mail using a gmail account. However, anything on the system sent to root needs to be forwarded to an external e-mail account. But when that happens, it gets returned from Google's gmail because it doesn't know what to do with a local domain:

Address not found Your message wasn't delivered to [email protected] because the domain foobaz.localdomain couldn't be found. Check for typos or unnecessary spaces and try again. 

So far, in /root/.forward I put in [email protected] and listed [email protected] in /etc/aliases for user 'root'.

Here is the diff on /etc/postfix/main.cf file from the original file that is provided with postfix:

[root@foobaz postfix]# diff ORIGINAL_main.cf main.cf 119c119 < inet_protocols = all --- > inet_protocols = ipv4 679a680,690 > > myhostname = foobaz > > relayhost = [smtp.gmail.com]:587 > smtp_use_tls = yes > smtp_sasl_auth_enable = yes > smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd > smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt > smtp_sasl_security_options = noanonymous > smtp_sasl_tls_security_options = noanonymous > 

In the past, I recall without changing anything a Linux CentOS system would allow e-mail addressed to 'root' to go to the root mailbox. But the way I have it configured now with postfix, it ships everything off to Google's gmail to be resolved there, and of course, it can't be because I'm not using fully qualified domain. In addition, it won't work because it needs to find its way to the actual 'root' user for the /root/.forward and /etc/aliases to do their magic.

How can I add this capability so gmail will still work the way it is now for sending e-mail to the outside world, yet know that user 'root' needs to stay local on the system so it can be delivered to the 'root' mailbox ultimately to be correctly forwarded to an external e-mail address?

This exactly changed to the main.cf is what made this work:

mydestination = foobaz.localdomain, $myhostname, localhost.$mydomain, localhost 

1 Answer 1

1

The relayhost is the next-hop destination of non-local mail, so you need to handle this hostname locally. As you want to handle the final destination using mappings in /etc/aliases, you need to list the hostname in mydestination.

  • Default:

    mydestination = $myhostname, localhost.$mydomain, localhost 
  • You hostname added:

    mydestination = foobaz.localdomain, myhostname, localhost.$mydomain, localhost 
6
  • Should that be $myhostname? Commented Jun 3, 2018 at 13:12
  • Yes, it works with $myhostname! I tried to edit it, but that wasn't enough text for it to accept the change. Commented Jun 3, 2018 at 13:23
  • That's ONLY because $myhostname is within mydestination by default. Commented Jun 3, 2018 at 13:30
  • Did you intend $myhostname or myhostname? Commented Jun 3, 2018 at 13:34
  • Both. The first is a variable containing the second. ;) Commented Jun 3, 2018 at 13:39

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.