How to change mailx?
Solution 1
So in the server1 you have heilroom-mailx i.e. /etc/alternatives/mailx -> /usr/bin/heirloom-mailx
, the second server uses bsd-mailx
.
Do apt-get install heirloom-mailx
on both servers if you want to have mailx from server1.
After installing, server should automatically use heirloom as mailx, if not do:
sudo update-alternatives --set mailx /usr/bin/heirloom-mailx
Solution 2
To expand on the answer from @darek and @nadir-latif /usr/bin/mail
is also an alternative and is a slave of the mailx
alternative, from checking Wheezy/Jessie installations the heirloom-mailx
priority was 60 so to install use
sudo update-alternatives --install /usr/bin/mailx mailx /usr/bin/heirloom-mailx \
60 --slave /usr/bin/mail mail /usr/bin/heirloom-mailx \
--slave /usr/share/man/man1/mail.1.gz mail.1.gz \
/usr/share/man/man1/heirloom-mailx.1.gz --slave \
/usr/share/man/man1/mailx.1.gz mailx.1.gz \
/usr/share/man/man1/heirloom-mailx.1.gz
which will allow setting both the mail
and mailx
alternatives. On Stretch the mail.mailutils
has a priority of 30 and from the man page
When a link group is in automatic mode, the alternatives pointed to by members of the group will be those which have the highest priority.
so if you use the priority of 60
and you have it set to automatic you will not need to explicitly set the alternative, otherwise as @darek states use
sudo update-alternatives --set mailx /usr/bin/heirloom-mailx
Related videos on Youtube
Chris
Updated on September 18, 2022Comments
-
Chris almost 2 years
I am having a problem in my VMs.
I used the same template (Debian 7min) in OpenVZ, but for whatever reason those two are using a different mailx. I have a small script which I use to send statusmails:
mailx -v -s "$subject" -S smtp=$smtphost -S from="$mailfrom" -S smtp-auth-user=$smtpuser \ -S smtp-auth-password=$smtppwd $emailto </dev/null
It works find on one server, the other one give me an error message 'unknown command -S'.
Ok, I know mailx is just a virtual package, and I usually install bsd-mailx, but both server show they are setup identical
ls -al /etc/alternatives/ma*
lrwxrwxrwx 1 root root 18 Feb 9 20:07 /etc/alternatives/mailx -> /usr/bin/bsd-mailx
dpkg --get-selections | grep mail
bsd-mailx install fetchmail install procmail install rmail install sendmail install sendmail-base install sendmail-bin install sendmail-cf install sendmail-doc install
Problem is, mailx like never supports any kind of version info, so mailx --help or --version just says 'unknown option' - so I cant even figure out what 'version' of mailx it is
This is output from server 1
mailx: illegal option -- - Usage: mailx -eiIUdEFntBDNHRV~ -T FILE -u USER -h hops -r address -s SUBJECT -a FILE -q FILE -f FILE -A ACCOUNT -b USERS -c USERS -S OPTION users
this is output from server 2
mailx: invalid option -- '-' usage: mailx [-dEIinv] [-a header] [-b bcc-addr] [-c cc-addr] [-s subject] to-addr ... [-- sendmail-options ...] mailx [-dEIiNnv] -f [name] mailx [-dEIiNnv] [-u user]
Clearly not idential. Any helps how I can 'get' the mailx from server 1 to server 2? I am out of ideas.
-
Nadir Latif over 6 yearsOn Debian Stretch before running the above command, you need to register the mailx alternative using the command:
update-alternatives --install /usr/bin/mailx mailx /usr/bin/heirloom-mailx 10