Linux Mail Command (send and receive mail) __linux

Source: Internet
Author: User
Tags auth how to send mail

Ubuntu:
First install mail
sudo apt-get install Mailx
Install postfix sudo apt-get install postfix again (configure during installation and follow the prompts)
Send mail Command sample cat "Content" | Mail-s "Subject" yl33643@126.com

In debian/ubuntu system apt-get Install mutt Apt-get install swaks apt-get install mailx apt-get Install Sharutils

In red Hat based systems such as CentOS or Fedora yum install mutt yum install swaks yum install mailx yum install Sharutil S


echo "This are the Body" | Mutt-s "Subject" test@example.com.cn

SendMail Configuration macro File:/ETC/MAIL/SENDMAIL.MC

Vi/etc/mail/sendmail.mc

Sharutils: (uuencode) 2 Send Attachments

1. How to view the Linux MailQueue
$mailq
$sendmail-BP
$ll/var/spool/mqueue This is the directory stored in the mail queue, you can delete the files inside to clear the MailQueue
You can use these commands to see if a message is sent

2. How to send mail
1 Send the file as the content of the email
Syntax: mail-s "subject" User name @ Address < file
For example:
$mail-S "Send with content this is a file" Sherry@geminimobile.com < Install.log
2) Transfer mail to the users of the system
$mail User Name
3) Edit the content of the message
$mail Sherry@geminimobile
Subject:messge for job edit title after carriage return
Apple this job. Start editing content, press Ctrl+d to exit content edit when finished
CC: Enter CC address, if no direct return to send mail
Note: Ctrl + C can interrupt mail editing
4 Send mail quickly
$echo "Message body" | Mail-s Message Subject Sherry@geminimobile.com
5) Send the attachment
$uuencode Attachment name Display attachment name | Mail-s "Subject" sherry@geminimobile.com
Note: Uuencode is the process of converting a binary file into a text file, the converted file can be transmitted by plain text e-mail, and the file is uudecode by the receiver, which is converted to the original binary file.

6 Add the-V option when sending mail to see the mail server response at the terminal

[Root@tc-40432-5s ~]# mail-v-S "Send with content this is a file" Sherry@geminimobile.com < Install.log
Sherry@geminimobile.com ... Connecting to [127.0.0.1] via relay ...
Localhost.localdomain ESMTP Sendmail 8.13.1/8.13.1; Mon, Dec 2010 14:40:13 +0800
>>> EHLO Localhost.localdomain
250-localhost.localdomain Hello tc-40432-5s [127.0.0.1], pleased to meet you
250-enhancedstatuscodes
250-pipelining
250-8bitmime
250-size
250-dsn
250-etrn
250-auth GSSAPI digest-md5 CRAM-MD5
250-deliverby
Help
>>> MAIL from:<root@localhost.localdomain> size=60054 auth=root@localhost.localdomain
2.1.0 <root@localhost.localdomain> Sender OK
>>> RCPT to:<sherry@geminimobile.com>
>>> DATA
2.1.5 <sherry@geminimobile.com> Recipient OK
354 Enter Mail, End with "." In a line by itself
>>>.
obd6edww006082 2.0.0 accepted for delivery
Sherry@geminimobile.com ... Sent (obd6edww006082 message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 Localhost.localdomain Closing connection

3. Mail received by the system will be saved in the/var/spool/mail/User name folder
By mail, typing mail displays the top 20 mail for the current user. You can view and delete messages. Type. All commands can be displayed
$mail
Mail version 8.1 6/6/93. Type? For help.
"/var/spool/mail/root": Messages Panax Notoginseng New
>n 1 root@localhost.local Mon Dec 11:55 21/940 "Cron <root@tc-40432-5s>/usr/sbin/logrotate/usr/lo Cal/gemini/hss/3.0.0-ga1/etc/logrotate-stats/hss-stats-rotate "
.
.
.
&?
Mail Commands
T <message list> type messages
N Goto and type next message
E <message list> Edit messages
F <message list> give head lines of messages
D <message list> Delete messages
s <message list> file append messages to File
U <message list> Undelete messages
R <message list> reply to message senders
R <message list> reply to Message senders and all recipients
Pre <message list> make messages to back To/usr/spool/mail
M <user list> mail to specific users
Q quit, saving unresolved messages in mbox
X

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.