1

Is there a way to change the outbound email for root, i.e instead of root@localhost.localdomain to root@apps.mydomain.com?

I am using Postfix.

Avatar
  • 127
  • 1
  • 1
  • 10
Rungano
  • 97
  • 1
  • 3
  • 12

4 Answers4

2

Modify the aliases file to your taste. It will be in /etc or /etc/mail or /etc/postfix or any other directory depending on your MTA. You may also need to rebuild alias db or reload your MTA (see the MTA documentation).

Max Alginin
  • 3,284
  • 15
  • 11
2

In Postfix set:

myhostname = host.example.com

in main.cf

Avatar
  • 127
  • 1
  • 1
  • 10
rkthkr
  • 8,618
  • 28
  • 38
0

Situation: I renamed the Digital Ocean Droplet (the old domain was gone), however, the root mail was still sending mails with the old domain (when executing bash scripts). The old email was visible in the email header:

envelope-from
Return-path:
From: root@old.domain.com (root)

Using hostname=newdomain.com then restarting the server did not help.

Likewise this did not help:

sudo postconf -e 'myhostname = newdomain.com'
sudo postconf -e 'smtp_helo_name = newdomain.com'
sudo service postfix restart

Then I looked into /etc/postfix/main.cf which reveals one important line:

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)

Finally, I could pinpoint the problem down to this file:

/etc/mailname

which was still having the old entry.

So I edited the file and set the new filename.

Afterwards in SSH I executed:

  1. newaliases (not sure if needed)
  2. sudo service postfix restart
  3. Then executed my custom bash script with mail.

And voila, the mail sent is from the new email address.

Avatar
  • 127
  • 1
  • 1
  • 10
0

I have found the solution its smtp_generic_maps (default: empty)

Optional lookup tables that perform address rewriting in the SMTP client, typically to transform a locally valid address into a globally valid address when sending mail across the Internet. This is needed when the local machine does not have its own Internet domain name, but uses something like localdomain.local instead.

Rungano
  • 97
  • 1
  • 3
  • 12