Configuremos el servicio postfix para que actué como smarthost y así poder enviar correos desde la terminal.
Instalamos los paquetes necesarios
$ yum install postfix mailx cyrus-sasl cyrus-sasl-plain -y
Configuración de credenciales
$ vim /etc/postfix/sasl_passwd
smtp.gmail.com user@gmail.com:miPassWord
$ postmap hash:/etc/postfix/sasl_passwd
Configurando postfix
$ vim /etc/postfix/main.cf
###################
# SMARTHOST GMAIL #
###################
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
Configurando los servicios:
$ systemctl stop sendmail.service
$ systemctl disable sendmail.service
$ alternatives --config mta
There are 2 programs which provide ‘mta’.
Selection Command
———————————————————————-
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.postfix
Enter to keep the current selection[+], or type selection number: 2
$ systemctl start postfix.service
Probando todo
$ echo "Hello world!" | mail -s "Prueba de correo" micorreo@test.com