One, the Mail command
1. Configure Vim/etc/mail.rc
Add the following to the end of the file
Set [email protected] smtp= "smtp.qq.com"
Set smtp-auth-user= "[email protected]" smtp-auth-password= "123456"
Set Smtp-auth=login
Description:From: The sender that appears when the other person receives the message
SMTP: Specify the SMTP server address for third-party outgoing messages
Smtp-auth:smtp authentication method. Default is login, can also be changed to CRAM-MD5 or plain mode
Smtp-auth-user: The user name of the third-party email
Smtp-auth-password: User name corresponding 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" pickup address
% mail-s "test" [email protected]
2) have the message body
- Mail-s "Subject" Pickup address < file (message body. txt)
% mail-s "mail subject" [email protected] </data/findyou.txt
- echo "Message body" | Mail-s Mail Subject Pickup Address
% echo "message body content" | mail-s "email subject" [Email protected]
- Cat message body. txt | Mail-s Mail Subject Pickup Address
% cat/data/findyou.txt | mail-s "email subject" [Email protected]
3) with accessories
- Mail-s "Subject" pickup address-a Attachment < file (message body. txt)
% mail-s "mail subject" [email protected]-a/data/findyou.tar.gz </data/findyou.txt
3. Scripts
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 "$4"]; Then
Mail-s $ ${mail_to}<$3
Else
Mail-s $1-a $4 ${mail_to}<$3
Fi
Use
[Email protected]]$/sendmail.sh test [email protected] Abc.txt
Send Mail to [email protected]
[[Email protected]]$
Original Blog Address
Linux Send mail