Use your Gmail mailbox to send mail under CentOS via Postfix

Source: Internet
Author: User
Tags email account

Cause:

[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/main.cf file.

Vi/etc/postfix/main.cf

Smtp_sasl_security_options = noanonymous

Relayhost = [smtp.gmail.com]: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

Mkdir-p/ETC/POSTFIX/SASL

vi/etc/postfix/sasl/passwd

[smtp.gmail.com]: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 [smtp.gmail.com]: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: https://security.google.com/settings/security/apppasswords

3. Change file permissions

chmod 600/etc/postfix/sasl/passwd

4. Create a lookup table

postmap/etc/postfix/sasl/passwd

5. Generate CA Certificate

Cd/etc/pki/tls/certs

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]

Cp/etc/pki/tls/certs/zhaoxinxing.pem/etc/postfix/cacert.pem

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 http://324703.blog.51cto.com/314703/1732878

Use your Gmail mailbox to send mail under CentOS via Postfix

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.