Linux Send mail

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.