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 [email protected]

I want the from address to be just [email protected]. 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

3 Answers 3

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).

3
  • Doesn't work on Ubuntu 18.04/mailutils 2.99.99. What version are you using? Nov 29, 2019 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, 2021 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 at 5: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 ).

3
  • 1
    Using mailutils.conf as described by @rustyx would appear to answer the question. Nov 3, 2019 at 9:35
  • 1
    @NiklasHolm Are you sure? I've just tried it on 18.04 and it works fine. Nov 30, 2019 at 8:21
  • /etc/mailname !
    – Martin T.
    Jan 25, 2021 at 11:10
-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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .