1. Install heirloom-mailx
sudo apt-get install heirloom-mailx
2. Modify /etc/s-nail.rc to add an external SMTP server as follows:
This is a read-only file, first change the permissions :
sudo chmod 777 /etc/s-nail.rc
Execute under ordinary users :
vim /etc/s-nail.rc
In the end of the file add: [ to ×××××××××× into your e-mail address ]
set from=××××××××××@qq.com
set smtp=smtps://smtp.qq.com:465
set smtp-auth=login
set smtp-auth-user=××××××××××@qq.com
set smtp-auth-password=Authorization code
The < authorization code > in the text , for qq mailbox, you need to log in to the web page qq mailbox, turn on the POP3/SMTP service or IMAP/SMTP service in the setting options, click the generate authorization code below, and get it by sending an SMS. As shown below:
3. Test it
echo 'Content' | mail -s "Title" ××××××××××@qq.com