Mail command
1. Configure
Add the following content to the end of the file
Set from=1968089885@qq.com smtp= "smtp.qq.com"
set smtp-auth-user= "1968089885@qq.com" 123456 "
Set Smtp-auth=login
Description
From: The sender that appears when the other person receives the message
SMTP: Specifies the SMTP server address for a third party to send mail
Smtp-auth:smtp authentication method. The default is login, which can also be changed to CRAM-MD5 or plain mode
Smtp-auth-user: Third party email user name
Smtp-auth-password: User name corresponds to password
2.Mail command
% mail--h
mail:illegal option---
usage:mail-eiiudefntbdnhrv~-t file-u user-h hops-r address-s SUBJECT- A file-q file-f file-a account-b users-c users-s OPTION USERS
Note: Some system parameters are slightly different, it is best to see Help
1) No message body
Mail-s "Subject" Inbox address
% mail-s "Test" 1968089885@foxmail.com
2) have the message body
Mail-s "Subject" Inbox < files (message text. txt)
% mail-s "Mail Subject" 1968089885@foxmail.com </data/findyou.txt
echo "Message body" | Mail-s Mail Subject Address
% echo "message body content" | Mail-s "Mail Subject" 1968089885@foxmail.com
Cat message body. txt | Mail-s Mail Subject Address
% Cat/data/findyou.txt | Mail-s "Mail Subject" 1968089885@foxmail.com
3) with Accessories
Mail-s "Subject" address-a Attachment < file (message text. txt)
% mail-s "Mail Subject" 1968089885@foxmail.com-a/data/findyou.tar.gz </data/findyou.txt
3. Script
sendmail.sh
#!/bin/bash
#author: Findyou help
() {
echo "eg: $ [Subject] [address] [content_file] [file]"
echo "
exit 1
}
if [!-n ' $ ']; Then
help
fi
cdate= ' Date +%y%m%d '
if [!-n ' $]; then
help
else
mail_to=$2
echo " Send Mail to ${mail_to} "
fi
if [!-n" $]; then
mail-s $ ${mail_to}<$3
else
mail-s $ A $ ${mail_to}<$3
fi
Use
[root@123]$./sendmail.sh test 1968089885@qq.com abc.txt
Send Mail to 1968089885@qq.com
[root@123]$
Note: It is recommended to use the command directly, there are scripts just to display relevant information in print, superfluous.
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.