I would the mail command to use a program other than /usr/sbin/sendmail.

$ mail --path=/usr/local/bin/mysendmail someone@somewhere.com

How can I do this?

  • What version of mail is this? – thrig Oct 21 '17 at 4:07
  • @thrig sorry yeah I should have mentioned. BSD-mail package in unbuntu repositories – the_velour_fog Oct 21 '17 at 4:09

For bsd-mail (which Debian calls the bsd-mailx package) a sendmail option can be set in the ~/.mailrc file:

set sendmail=/root/alternatemailer

Which could instead be ssmtp or something or a simple shell script to test that this even works as documented.

$ cat /root/alternatemailer
cat >> /root/meh
$ rm /root/meh
$ echo foo | mail -s blah nobody@example.org
$ file /root/meh
meh: ASCII text

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.