Home  >  Article  >  Operation and Maintenance  >  How to send email in centos

How to send email in centos

王林
王林Original
2020-03-18 11:46:112995browse

How to send email in centos

1. Install sendmail and mail

1. Install sendmail:

1) You can install the command under centos:

yum -y install sendmail

2) After installation, start the sendmail command:

service sendmail start

(Recommended tutorial: centos usage tutorial)

2. Install mail

Installation command:

yum install -y mailx

2. Send email

1. Send through file content

Send command:

mail -s &#39;mail test&#39; xxx@yyy.com < con.txt

("mail test" is the email subject, xxx@yyy .com is the recipient's email address, con.txt saves the email content)

2. Send directly through the pipe character

Send command:

echo "this is my test mail" | mail -s &#39;mail test&#39; xxx@yyy.com

3. Settings Sender information

The above-mentioned email will use the current Linux login user information by default, which is usually regarded as spam. Specify the sender email information command: vi /etc/mail.rc, and edit the content such as:

set from=username@126.com
set smtp=smtp.126.com
set smtp-auth-user=username
set smtp-auth-password=password
set smtp-auth=login

Note that the smtp-auth-password in the configuration is not the mailbox login password, but the authorization code for the mailbox server to open SMTP. The operation of opening the authorization code for each mailbox is different (NetEase 126 mailbox opening menu: Settings-> Client authorization password).

Recommended related video tutorials: linux video tutorial

The above is the detailed content of How to send email in centos. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn