Use your Gmail mailbox to send mail under CentOS via Postfix

Source: Internet
Author: User
Tags email account


[Email protected] ~]# echo 123|mail-s "123" [email protected]

[Email protected] ~]# smtp-server:530 5.7.0 must issue a STARTTLS command first. 71sm664699pfs.63-gsmtp

"/root/dead.letter" 11/317

... message not sent.

QQ mailbox has been used to send their own e-mail, do data backup, today I want to change QQ mailbox Gmail mailbox, the results appear above the error, the Internet to find the next information finally resolved, but the pit more than halfway, summed up a convenient future encounter pit.

For ease of viewing, the input command is indicated in red, and Blue indicates what is entered

1. Add the following fields at the end of the/etc/postfix/ file.


Smtp_sasl_security_options = noanonymous

Relayhost = []:587

Smtp_use_tls = yes

Smtp_tls_cafile =/etc/postfix/cacert.pem

Smtp_sasl_auth_enable = yes

Smtp_sasl_password_maps = hash:/etc/postfix/sasl/passwd

2. Configure SASL Certification

Create passwd file and add account password information



[]:587 your e-mail: application-specific password

Note the ":" between the email account and the password, and don't miss out. For example: My company purchased Google Mail Service, I generated a password is 123qwe configuration []:587 [e-mail Protected]:123qwe

With Google's security restrictions, use a non-web-only way to set the app-specific password

Application-specific password generation Web site:

3. Change file permissions

chmod 600/etc/postfix/sasl/passwd

4. Create a lookup table


5. Generate CA Certificate


Make your name. PEM #例如: My name is xiaoming, then make Xiaoming.pem

Umask 77; \

Pem1= '/bin/mktemp/tmp/openssl. XXXXXX '; \

Pem2= '/bin/mktemp/tmp/openssl. XXXXXX '; \

/usr/bin/openssl req-utf8-newkey rsa:2048-keyout $PEM 1-nodes-x509-days 365-out $PEM 2-set_serial 0; \

Cat $PEM 1 > Xiaoming.pem; \

echo "" >> Xiaoming.pem; \

Cat $PEM 2 >> Xiaoming.pem; \

Rm-f $PEM 1 $PEM 2

Generating a 2048 bit RSA private key



Writing new private key to '/tmp/openssl.ghsn9f '


You is about-to is asked to-enter information that'll be incorporated

into your certificate request.

What's about-to-enter is called a distinguished Name or a DN.

There is quite a few fields but can leave some blank

For some fields there would be a default value,

If you enter '. ', the field would be a left blank.


Country Name (2 letter code) [XX]:cn

State or province name (full name) []:Beijing

Locality Name (eg, city) [Default City]:Beijing

Organization Name (eg, company) [Default company LTD]:gongsi

Organizational Unit Name (eg, section) []:It

Common name (eg, your name or your server ' s hostname) []:xiaoming

Email Address []:[email protected]


7. Restart Postfix Service

/etc/init.d/postfix restart

8, testing, completion

Send the/etc/hosts file as an attachment to your Gmail mailbox.

echo "Mail Test" |mail-a/etc/hosts-s "hosts" [email protected]

This article is from the "meiyou" blog, make sure to keep this source

Use your Gmail mailbox to send mail under CentOS via Postfix

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.