Você pode usar o sendEmail
Sobre o SendEmail
SendEmail is a lightweight, command line SMTP email client. If you have the need to send email from a command line, this free program is perfect: simple to use and feature rich. It was designed to be used in bash scripts, batch files, Perl programs and web sites, but is quite adaptable and will likely meet your requirements. SendEmail is written in Perl and is unique in that it requires NO MODULES. It has an intuitive and flexible set of command-line options, making it very easy to learn and use. SendEmail is licensed under the GNU GPL, either version 2 of the License or (at your option) any later version. [Supported Platforms: Linux, BSD, OS X, Windows 98, Windows NT, Windows 2000, & Windows XP]
Seguindo o script eu usei para instalar o sendEmail e enviar e-mail para o gmail id no CentOS / RHEL
#!/usr/bin/env bash
# Define sender's detail email ID
From_Mail="[email protected]"
# Sender's Username and password account for sending mail
Sndr_Uname="${From_Mail}"
Sndr_Passwd="your_password"
# Define recepient's email ID
To_Mail="[email protected]"
# Define CC to (Note: for multiple CC use ,(comma) as seperator )
# CC_TO="[email protected]"
# Define mail server for sending mail [ IP:PORT or HOSTNAME:PORT ]
RELAY_SERVER="smtp.gmail.com:587"
# Subject
Subject="Test Mail using SendEmail"
# sendEmail download link
download_sendEmail="http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz"
# Mail Body
MSG() {
cat <<_EOF
Dear Sir,
Please find the attachment of PDF File
_EOF
}
# store loggin information in below log file
Log_File="/var/log/sendmail.log"
# check sendmail dir exists or not if not check create it
Log_dir="$(dirname ${Log_File})"
if [ ! -d "${Log_dir}" ]; then
mkdir "${Log_dir}"
fi
check_sendmail() {
if [ ! -x "/usr/bin/sendEmail" ]; then
echo "sendEmail not installed"
echo "Installing sendEmail..."
sleep 1s
wget -cnd "${download_sendEmail}" -O /tmp/sendemail.tar.gz >/dev/null 2>&1
tar -xzf /tmp/sendemail.tar.gz --wildcards *sendEmail
install --mode=744 sendEmail*/sendEmail /usr/bin/
yum install perl-Net-SSLeay perl-Net-SMTP-SSL -y
fi
}
check_sendmail
/usr/bin/sendEmail -v -f ${From_Mail} \
-t ${To_Mail} -u "${Subject}" \
-m 'MSG' \
-xu "${Sndr_Uname}" \
-xp "${Sndr_Passwd}" \
-o tls=auto \
-s "${RELAY_SERVER}" \
-cc "${CC_TO}" \
-l "${Log_File}"
Você pode usar a opção -a
para o anexo de arquivo no comando sendEmail