0

This appears to be a common issue but none of the solutions I've come across seem to be working. I'm using Ubuntu 18.04 LTS and mailutils / postfix. My /etc/postfix/main.cf looks like this:

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no
compatibility_level = 2
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = mydomain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = $mydomain
mydestination = $myhostname, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = all

My /etc/aliases has the following entry:

root: myuser@mydomain.com

Note I want mail to default to user@mydomain.com when I don't specify a from address. Any suggestions are welcome! I've tried this and this but no success

R2Bleep2
  • 29
  • 6

1 Answers1

2

Postfix doesn't send mail.

It transfers mail to other servers and receives mail from other servers.

Sender is specified by the Mail User Agent, not the Mail Transfer Agent. Set whatever sender you want in whatever software you use to send the e-mail to Postfix for handling.

For mailutils' mail command, a man mail is suggested reading:

from The address (or a list of addresses) to put into the `From:' field of the message header. If replying to a message, these addresses are handled as if they were in the alternates list. If the machine's hostname is not valid at the Internet (for example at a dialup machine), either this variable or hostname have to be set to get correct Message-ID header fields. If from contains more than one address, the sender variable must also be set.

Try mail -a FROM:foobar@example.org barfoo@example.com as a test of how to set the sender.


If you're really set on fixing this in the wrong place, you can always have a look at how Postfix can rewrite e-mail addresses. Masquerade is probably what you want:

masquerade_domains = example.com

should strip foo.example.com to example.com. But please; don't go this route. Fix the problem at the origin; the MUA that sends the e-mail to Postfix.

vidarlo
  • 3,775
  • 1
  • 12
  • 25
  • I was explicit about using mailutils in conjunction with postfix above. In light of your answer, my question is: how do I have the mail bash utility send from user@mydomain.com when I don't specify a from address? – R2Bleep2 Jun 29 '21 at 09:17
  • `-a FROM:foobar@example.org` will change the sender for mail in mailutils... – vidarlo Jun 29 '21 at 19:47
  • So mailutils cannot be configured to do that without being explicit about the from address? – R2Bleep2 Jul 14 '21 at 06:56