Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a fleet of Ubuntu clients running msmtp-mta along with heirloom-mailx. I'd like to have the same /etc/msmtprc on all machines.

At present, when someone uses mailx or sendmail, the mail will be from user@mydomain.com and the only clue to the client machine is the IP address in the mail header.

Is there a way to add the client host name to every mail sent? Like

  • Prepend it to the subject or
  • auto-attach a file to any mail or
  • change mydomain.com to client.mydomain.com (remember, one file to rule them all, and changes in host name should be met automatically)

Note: I cannot configure the actual SMTP-Server, just the msmtp client.

share|improve this question
You could try ssmtp instead of msmtp. I use msmtp myself, but you have to set the maildomain in the msmtprc for that; ssmtp uses the hostname directly I think. If you can settle for "the same msmtprc except for the maildomain", then client.mydomain.com should be possible with msmtp. – frostschutz Apr 9 '13 at 17:31
Nice one, frostschutz! I would upvote you if I could! Note: I installed both (m|s)smtp, let msmtp provide sendmail so users can use mailx as they are used to. root and other reporting system accounts get a .mailrc that uses ssmtp as sendmail and hence provide the one-to-rule-them-all host name config /etc/ssmtp/ssmtp.conf. – arney Apr 9 '13 at 21:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.