The command line sends an email, and the linux Command Line sends an email.

Source: Internet
Author: User

The command line sends an email, and the linux Command Line sends an email.
CentOS

  • Stop or remove sendmail: yum remove sendmail
  • Yum install postfix
  • Yum install mailx
  • Check whether the MTA is Postfix: alternatives -- display mta
  • If you do not change the default MTA to Postfix:/usr/sbin/alternatives -- set mta/usr/sbin/sendmail. postfix
  • Detect and start Postfix
    • service postfix status
    • service postfix start
  • Set chkconfig postfix on

OSXUse sendemailhttp: // blog.sciencenet.cn/blog-233665-407470.html
Send Email:

The simplest method:

Mail-s text ** @ mail.ustc.edu.cn

The result of this command is to send an empty message with the title text to the subsequent mailbox, but this type of mail is often treated as spam, so if you do not receive the mail, we recommend that you open the recycle bin to check it. first, you can use the current shell as an editor. After the content is edited, press Ctrl-D.

# Method 2: Use the pipeline command

Echo "This is a test mail !" | Mail-s text ** @ mail.ustc.edu.cn

# Method 3: Use redirection.

Mail-s test ** @ mail.ustc.edu.cn <file

To send a mail with the file content, first select to write a document in advance and then mail it in the past.

Emails with attachments (important)

If you do not have the uuencode command in your system, you need to install sharutils first,
Sudo apt-get install sharutils.
Uuencode requires two parameters. The first is the file you want to send. Of course, this can also be done using pipelines, and the second is the file name displayed.
Uuencode/home/daniel/httpd. conf httpd. conf | mail-s mailtest ** @ mail.ustc.edu.cn



Http://www.cmhello.com/lnmp-centos-postfix.htmlhttp://blog.csdn.net/daniel_ustc/article/details/9383183

In linux, how does one send an email under the command line?

By default, the mail sending function is enabled in linux, but only mails can be sent between linux users, and external mails cannot be sent.
Method:
1. Check whether the sendmail process is enabled. In shell, enter ps-aux | grep 'sendmail'
2. Use the mail command to send an email, for example, to the root user
Mail-s 'send mail' root press ENTER
3. Enter the email content
4. Press ctrl + d to send and press ctrl + c to exit
5. Switch to the root user and you will see an email, which is stored in the/var/mail/root file.
Mail command usage: mail-s 'mail title' User Name
You can search for mail commands

Q: Is there a command for sending emails in windows?

Are you in dos622 or dos7.0?
You can use telnet mail. xxx. xxxx. xxx 25 to send emails.

220 **************************************

After receiving this information, you can use the following commands in sequence (Note: The order cannot be changed) to send emails.

Step1. enter the helo email user name

If the request (command) is successfully accepted, the remote smtp server will respond to the following information:

250 username <211.91.133.66> okay.
Step2. enter the command mail from:

If the request is successfully accepted, the remote smtp server will respond to the following information:
250, sender OK.

Step3. enter the command rcpt:

If the request is successfully accepted, the remote smtp server will respond to the following information:
250, Local recipient OK.

Step 4. Enter the command data

If the request is successfully accepted, the remote smtp server will respond to the following information:
354 Start mail input; end.

Now all emails are ready, and the system will wait for you to enter the body of the email. Note: You can only edit the email by using the telnet tool, the line above can no longer be changed. It also needs to be explained, that is, how the mail body ends. In fact, it is very simple. You only need to enter an English ending (.) After you press Enter (.), press enter to complete the process. The terminal displays the following information:

250 Requested mail action okay, completed.

Finally, do not forget to use the quit command to exit the connection to ensure that the mail can be sent normally. During the mail process, when the user inputs one or another wrong command, the system will give the corresponding error prompt, but these prompts are all written in English, some netizens may not be sensitive to English. Here I will describe several common error prompts: (the number is the status code of the Response Information)

500: syntax error. do not recognize this command
501: syntax error in command parameters or variable elements
503: Incorrect command order
553: the mail processing process has not occurred

Note: When you enter the command, it is unrealistic. I use imail, no problem.

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.