Send Emails by console with sendmail

This case was tested in Canaima and Ubuntu

1- We install SendEmail:

apt-get install sendemail

2- We install the following packages necessary for its correct operation with GMail:

apt-get install libnet-ssleay-perl

apt-get install libio-socket-ssl-perl

Now we are ready to send our emails. To use our GMail account, we type in the console:

sendemail -f [email protected] -t [email protected] -s smtp.gmail.com:587 -u \
"Asunto" -m "Cuerpo del mensaje" -a archivoadjunto -v -xu nombrecuenta -xp clavecuenta -o tls=yes

Where:

«[email protected]»Is our GMail account

«[email protected]»Is the account to which we want to send our mail (if we want to send to several recipients we just have to leave a blank space between the email addresses)

In "Subject:»Goes exactly the subject of the mail (if it goes between quotes) and in«Message body»What we want to write (also in quotes)

The option -a goes if we want to send an attachment

«accountname»Is the name of our GMail account without the @

«password account»Is our password to our GMail account

Now now a small script made in bash to send a mailing list in txt

#!/bin/bash
# -*- ENCODING: UTF-8 -*-
i=0
while read line
do i=$(($i+1));
sendemail -f [email protected] -t $line -s smtp.gmail.com:587 -u "TITULO" -m "CUERPO DEL MENSAJE" -v -xu nombredeusuariosinelaroba -xp contraseña -o tls=yes
done < "/home/direccion/correos"
echo "Final line count is: $i";


Add as preferred source in Google