Ubuntu – Configure ‘mail’ command to send external email when servers domain name is used


I have postfix and mail installed on my server.

The following command works fine

$mail aj@xyz.com

But if I use this command

$mail aj@mydomain.com  

The system thinks I am trying to send a local email to the user 'aj'. How can set mail to send emails to aj@mydomain.com externally?

The output from /etc/mailname is

$cat /etc/mailname 

The output from /etc/mail.rc

$cat /etc/mail.rc
set ask askcc append dot save crt  
ignore Received Message-Id Resent-Message-Id Status Mail-From Return-Path Via Delivered-To

Best Answer

From [1] pg 832

Another parameter we should set is mydestination, which specifies the mail domains that are local.

The changes which are relevant to my question:

Change the mydestination setting in /etc/postfix/main.cf to be blank.

mydestination = 


sudo postfix reload

[1] Unix and Linux system administration handbook, 4ed, 0-13-148005-7, 978-0-13-148005-6

Related Question