The Mail command for Linux email

Source: Internet
Author: User

One, the Mail command
1. Configuration
Vim/etc/mail.rc

Add the following to the end of the file

Set from= [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 " 1968089885@foxmail. com

2) have the message body

    • Mail-s "Subject" Pickup address < file (message body. txt)
% mail-s " Mail subject " 1968089885@foxmail. com </data/findyou.txt
    • echo "Message body" | Mail-s Mail Subject Pickup Address
% echo " message body content " | Mail-s " Mail subject " 1968089885@foxmail. com
    • Cat message body. txt | Mail-s Mail Subject Pickup Address
% Cat /data/findyou.txt | mail-s " Mail subject " 1968089885@ Foxmail.com

3) with accessories
    • Mail-s "Subject" pickup address-a Attachment < file (message body. txt)
% mail-s " Mail subject " 1968089885@foxmail. Com-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 $ 1${mail_to}<$ 3
Else
Mail-s $ 1-A $ 4${mail_to}<$ 3
fi

Use

[[Email protected] 123]$./sendmail. SHTest 1968089885@qq. com abc.txt
Send Mail to 1968089885@qq. com
[[Email protected] 123]$

Description: It is recommended to use the command directly, there is script just to display relevant information in print, superfluous.


The Mail command for Linux email

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.