Linux Mail command send mailbox directly method

Source: Internet
Author: User
Tags auth


Mail Configuration

Configure new MAILX to use external mailboxes to send mail:


Edit/etc/nail.rc (Note that is not an older version of/etc/mail.rc): vi/etc/nail.rc

Add two lines:

Set from=myname@qq.com smtp=smtp.qq.com
Set Smtp-auth-user=myname Smtp-auth-password=password Smtp-auth=login


Testing of mail commands on Linux systems

1. One of the simplest examples:

Mail-s Test yangfang@fudan.edu.cn

The result of this command is to send an empty letter titled Test to the back of the mailbox, and if you have an MTA and the following mailbox does not block this possibly inexplicable letter, you will receive this letter. If you don't want to be distracted by this mess, use a local account on the back of your mailbox.


2. Second example:

Three common format letters

Mail-s Test yangfang@fudan.edu.cn #第一种方法, you can use the current shell as an editor, edit the content ctrl-d end

echo "Mail Content" |mail-s test yangfang@fudan.edu.cn #第二种方法, I use the most, may be like the reason of the pipeline

Mail-s Test yangfang@fudan.edu.cn < file #第三种方法 to send messages to the contents of file

In fact, you can easily find mail from the standard input to read the contents of the file and send a letter, I just want you to know this, to this, the second example of the end.

3. Third example, a message with an attachment

If there is no uuencode command in your system, please install Sharutils (yum install sharutils) first.

Uuencode need two parameters, the first is the file you want to send (we), of course, this can also be done by pipeline, the second is the file name displayed

Uuencode/home/yfang/a.gif a.gif|mail-s pictest yangfang@fudan.edu.cn

Tar Czf-/home/yfang/| Uuencode home.tgz |mail-s pictest yangfang@fudan.edu.cn

PS: By the way, Slackware Mail seems to have a-a parameter, you can add the attachment directly, I have not used.


When you enter mail in Linux, you proceed to the Inbox and display 20 mailing lists.

At this point, the command prompt is "&"
Unread marked as unread mail
H|headers Displays the current mailing list
L|list display list of currently supported commands
?| Help displays command parameter usage for multiple view mailing lists
D Delete the current message, and move the pointer down. D 1-100 Delete 1th to 100th email
F|FROM displays only simple information about the current message. F num Display simple information about a message
F|from num pointer moves to a message
Z shows the next 20 mailing lists when you just made your inbox
More|p|page reading the contents of the current pointer, press the SPACEBAR to turn the page, press ENTER to move down one line
T|type|more|p|page Num Read an email
N|next| {Do not fill in} read the next message that contains the current pointer
When reading, press the space bar is the page, press ENTER is to move down one line
V|visual current message into plain text editing mode
N|next| {Nothing to fill} num read an email
Top displays the message headers for the message that contains the current pointer
File|folder displays information about the file where the system message resides and the total number of messages
X exits the Mail command platform and does not save previous actions, such as deleting messages
Q exits the Mail command platform, saves the previous operation, such as deleting a message that has been deleted with D, and the read message is transferred to the mbox file in the current user's home directory. If you delete a file in mbox, it will be deleted completely.
When you enter Mail-f mbox on the Linux text command platform, you can see the messages in the mbox in the current directory.
CD changes the location of the current folder
When writing a letter, press CTRL + two times to interrupt the work and not send the letter.
When reading a letter, press CTRL + C to exit the reading status.

Send mail slow

Generally causes the Linux system to use SendMail, and then in PHP Mail () to send messages slow, is the slow DNS resolution caused, and often because the server hostname is not a real resolvable domain name. To solve this problem, just make sure that two points:
[*]/etc/mail/local-hosts-names domain names appear in the/etc/hosts; [the domain name used by *]hostname must be a real domain name to be resolved. How to modify the Linux system's hostname, you can use the hostname--help command to look at the instructions

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.