JuangaCovas.info

La página personal de Juan Gabriel Covas

Herramientas de usuario

Herramientas del sitio


linux:howtos:mailx-snail-el7-el9

Using s-nail to send mail (auth SMTP) via Enterprise Linux 9

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:

  • We have to set v15-compat
  • We have to use mta, not smtp
  • Since v15 will be mandatory soon, we have to set user:pass@host syntax in the URL of mta, so the @ symbol of user, if needed, HAS to be encoded as %40
  • ssl-verify becomes 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. Buy me a coffee, pls ;)

linux/howtos/mailx-snail-el7-el9.txt · Última modificación: 23/03/2024 05:01 por Juanga Covas