I would like to send mails to local users (mail username -s test <<< "test"
) and let sendmail add the domain. Sending mail to the full address (mail username@domain.tld -s test <<< "test"
) works, but if I only specify username
then the mail is send to username@hostname.domain.tld
which is not valid.
I read about masquerading and added this to /etc/mail/sendmail.mc
:
MASQUERADE_AS(`domain.tld')dnl
FEATURE(`masquerade_envelope')dnl
FEATURE(`masquerade_entire_domain')dnl
FEATURE(`always_add_domain')dnl
MASQUERADE_DOMAIN(`hostname')dnl
MASQUERADE_DOMAIN(`hostname.domain.tld')dnl
MASQUERADE_DOMAIN(`domain.tld')dnl
restarted sendmail
(sendmail.cf
is automatically rebuild) but /var/log/mail.log
still tells me that sendmail
sends to the address with the hostname included.
How can I add @domain.tld
to local usernames?
Edit
Requested output:
# as username
$ /usr/sbin/sendmail -Ac -bv username
Notice: -bv may give misleading output for non-privileged user
username... deliverable: mailer relay, host [127.0.0.1], user username@hostname.domain.tld
Best Answer
It turned out that the masquerading options need to be placed in
/etc/mail/submit.mc
. These were all the lines needed:Regenerate submit.cf if that isn't done automatically for you and restart
sendmail
and it works.