How to send email in centos

王林
Release: 2020-03-18 11:46:11
Original
3014 people have browsed it

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
Copy after login

2) After installation, start the sendmail command:

service sendmail start
Copy after login

(Recommended tutorial: centos usage tutorial)

2. Install mail

Installation command:

yum install -y mailx
Copy after login

2. Send email

1. Send through file content

Send command:

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

("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
Copy after login

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
Copy after 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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template