To send mail from the CLI or command line, Enterprise Linux 9 like Rocky Linux 9
introduces some changes, like having to use s-nail
instead of mailx
package (which was common under CentOS 7 for example).
A typical one-liner to send the contents of a file as the body message, remains the same:
# cat my_body_message.txt | (/usr/bin/mail -v -s "My subject" -r from@address.com to@address.com)
BUT…
Previously, under CentOS 7 we had mailx
and could configure this to use an “authenticated” SMTP server:
/etc/mail.rc
globally or for your user: ~/.mailrc
# starttls needed for Gmail for example # set smtp-use-starttls set smtp=smtps://securesmtp.example.com:465 set smtp-auth=login set smtp-auth-user=username@domail.tld set smtp-auth-password=mypassword set ssl-verify=ignore set nss-config-dir=/etc/pki/nssdb/
Now in Rocky Linux 9 (or any EL 9 clone) we should configure it like this:
v15-compat
mta
, not smtp
mta
, so the @
symbol of user, if needed, HAS to be encoded as %40
tls-verify
set v15-compat # starttls needed for Gmail for example # set smtp-use-starttls # set mta=smtps://securesmtp.example.com:465 set mta=smtps://user%40domain.tld:mypassword@securesmtp.example.com:465 set smtp-auth=login # set smtp-auth-user=user@domain.tld # set smtp-auth-password=mypassword # set ssl-verify=ignore set tls-verify=warn set nss-config-dir=/etc/pki/nssdb/
You're welcome. Want to buy me a coffee? ;)