14

I have installed mailutils on Ubuntu 12.10 and I have run into a problem where the domain being attached is the fully qualified host and not just the domain. For example,

mail user2 [enter] then enter message and send produces a from address of user1@host.domain.com

I want the from address to be just user1@domain.com. I did not have this problem in 12.04, it only started when I upgraded to 12.10. Is there a system config file somewhere that would allow me to only set the domain.com as being added to the username when sending mail and not the full host name?

Thanks, Tim

Tim
  • 141
  • 1
  • 1
  • 5

3 Answers3

27

To use a local domain other than the hostname in Mailutils:

Create a file /etc/mailutils.conf with the following contents:

address {
  email-domain somedomain.com;
};

You can see what else can be configured in mailutils.conf with:

$ mail --config-help

For more configuration possibilities for the mail command using the .mailrc file, refer to the GNU Mailutils Manual. One useful setting is set xmailer=false to stop disclosing the Mailutils version in the X-Mailer header.


Note: /etc/mailutils.conf influences only the mail command. It has no effect on submitting email via sendmail, SMTP to localhost:25, etc. - for those use your MTA's "qualify domain" feature (e.g. /etc/mailname, or qualify_domain = somedomain.com in exim4.conf).

rustyx
  • 917
  • Doesn't work on Ubuntu 18.04/mailutils 2.99.99. What version are you using? – Niklas Holm Nov 29 '19 at 13:08
  • 2
    It worked fine for me in 18.04 back in 2018 and is still working in 20.04 and 20.10. – rustyx Feb 13 '21 at 11:18
  • @NiklasHolm: I can confirm this works on Ubuntu 18.04 (but GNU mailutils 3.4 instead, as per ubuntu's extended support).

    Curiously, mail --config-help says "For use in global configuration file (/etc/mailutils.conf), enclose it in program mail { ... };", but this was not needed

    – MestreLion Jan 13 '24 at 05:09
1

Frustratingly there is no easy generic mailutils configuration file way to do what you are asking (have the mail program from mailutils use a different default domain through said configuration file).

FWIW I've found that mailutils mail crafts addresses that look like user@host when sending a mail to just 'user' before the mail is given to the MTA. Thus how the FQDN is actually created was down to the MTA configuration (e.g. you can configure some MTAs to always append the contents of /etc/mailname thus creating other problems). That might explain why other answers on this question linked to the other answers explaining how to make to force headers when using mail (e.g. https://stackoverflow.com/a/380573/4513656 ).

Anon
  • 27
-1

You can do this by changing the hostname, or using the -F option of the mail command.

See also https://stackoverflow.com/questions/54725/change-the-from-address-in-unix-mail

Deim0s
  • 139
  • 4