I was trying to send an email to multiple persons using mailx (mailx (GNU Mailutils) 3.4). I did that successfully on a previous version of Ubuntu, v16.04, and the script was working fine. Now I have Ubuntu 18.04 and the following problem:

mailx: unrecognized option -S
mailx: unrecognized option -S
mailx: unrecognized option -S

what should I do?

My script is as follow:

while IFS=";" read name mailAdress
     printf "Dear $name, \n\n something something... "  | mailx -s "Title" -S smtp=smtps://mySMPTadress -S smtp-auth=login -S smtp-auth-user="MyUserName" -S smtp-auth-password='MyPassword' -S from="MyName <MyEmailAdress>"  mailAdress
done < "$FILE"

file speakers.csv looks like this

Klaus A;klaus@*****.de
Alessandra B;alessandra@****.it
Serge C;serge@****.fr
  • DId you try mail instead of mailx? maybe deprecated! – user88036 Sep 18 '18 at 11:45
  • Thanks for the acceptance, favour returned: Question upvoted! ;-) (For my curiosity: which solution did you take?) – Fabby Sep 19 '18 at 18:54

Quick and dirty:

mailx is a link to s-nail so you should use s-nail instead as according to its Bionic man page it still has the -S option.

Do it properly:

You should avoid sending mail like that because anyone that has access to ps can read your password as it's on the command line and you should look into using the -A (account) option to store this in the .netrc file that only the user and root have access to. (Read the full man page)


Debian and Ubuntu have replaced Heirloom mailx with s-nail mailx. Both support that option. But there are several other mailx commands from other packages which do not, including the GNU Mailutils mailx which you have apparently unknowingly switched to.

On the gripping hand, as Fabby said, do not pass user credentials around in command arguments (or environment variables).

Further reading

  • mailx. Ubuntu 16.04 manual pages.
  • mailx. Ubuntu 16.04 manual pages.
  • mailx. Ubuntu 16.04 manual pages.
  • mailx. Ubuntu 14.04 manual pages.
  • s-nail. User commands. s-nail. Debian manual pages.
  • mailx. User commands. GNU mail utils. Debian manual pages.
  • mailx. General Commands Manual. BSD mailx. Debian manual pages.
  • mailx. User commands. NMH. Debian manual pages.
  • Difference between mail and mailx?
  • +1 just for using on the gripping hand. (also: I wasn't aware that OP switched to GNU mail utils...) ¯\_(ツ)_/¯ – Fabby Sep 19 '18 at 18:57

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.