[mail command] How to use mail command to send E-mail
1. sudo apt-get install ssmtp
2. sudo vim /etc/ssmtp/ssmtp.conf
root=<Empty>
mailhub=smtp.gmail.com:587 <-- No Set this option. Mail can be send.
AuthUser=<UserName>
AuthPass=<UserName-Password>
UseTLS=YES
UseSTARTTLS=YES
rewriteDomain=gmail.com
hostname=<Empty>
FromLineOverride=YES
3. Test
mail -s "test mail" <UserName>@gmail.com < XXX.txt
or
echo "This is a test mail." | mail -s "test mail" <UserName>@gmail.com
or
This command can send mail include the file.
c.txt <-- This is the content of E-mail.
mpack -s happy -d ./c.txt ./a.txt luke_fang@unihancorp.com
If don't want any content in the E-mail
mpack -s happy ./a.txt luke_fang@unihancorp.com
Reference :
How to send email alerts from Ubuntu Server using ssmtp
使用 ssmtp 於 shell 透過 Gmail 寄信
FourDollars Blog
How do I send a file as an email attachment using Linux command line?
mpack(1) - Linux man page
0 意見:
張貼留言