HanG321 Blog
Be Shine, Be Smile, Be Wild
  • Home
  • Blog
    • 好文閱讀 readings
    • 生活記事 diary
    • 時事評論 commentary
    • 科技資訊 technology
    • 電腦編程 programming
    • 金融財經 finance
    • 音樂電影 music/movie
  • About
CentOS Postfix 使用 Gmail SMTP 發送信件

CentOS Postfix 使用 Gmail SMTP 發送信件

September 22, 2016|CentOS, gmail, google, Linux, postfix, smtp|電腦編程

CentOS 6

1. 移除sendmail 安裝postfix

# /etc/init.d/sendmail stop
# yum remove sendmail
# yum install postfix cyrus-sasl mailx

2. Gmail username and password

Simple Authentication and Security Layer (SASL)

# echo "smtp.gmail.com  GMAIL_USERNAME:GMAIL_PASSWORD" > /etc/postfix/sasl_passwd
# chmod 600 /etc/postfix/sasl_passwd
# postmap hash:/etc/postfix/sasl_passwd

3. Postfix 設定 vim /etc/postfix/main.cf

myhostname = xxxx.hang321.net
mydomain = hang321.net

# use Gmail SMTP server. Remember to set on Google to allow access with less secure method
relayhost = smtp.gmail.com:587

smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous

# set the required TLS options
smtp_tls_CApath = /etc/ssl/certs
smtp_tls_security_level = secure
smtp_tls_mandatory_protocols = TLSv1
smtp_tls_mandatory_ciphers = high
smtp_tls_secure_cert_match = nexthop

CApath here, not CAfile

4. 重新啟動Postfix

# service postfix restart

5. Google 安全性設定

https://myaccount.google.com/security

「我的帳戶」> 「低安全性應用程式」專區 > 「安全性較低的應用程式存取權限」旁邊的 [啟用]

6. 測試mail server 是否有正常寄信

寄信俾自己

Testing email, tail -f /var/log/maillog to see the result.
# echo "body of your email" | mail -s "This is a Subject" [email protected]

 

後記:

Goolge 可能係最近才有這個安全性設定,大多數reference 都沒有提及,搞到我白忙一場。
不同Linux distro, CA file name 有分別。

elder scroll online

July 4, 2015|生活記事

最近花了太多時間在MMORPG elder scroll online 上. 幸好 (不幸) 今天PS4 server 又死掉, 走去搞下個docker, 個SSD 都唔夠位放images, 都係早D set 做其他位置好d .

getting started with Docker on Mint 17

July 4, 2015|Docker, mint|電腦編程
## installation
sudo apt-get install apparmor lxc cgroup-lite
sudo apt-get install docker.io

## verification
sudo service docker.io start
sudo docker run hello-world

## show current images
sudo docker images

## view location
sudo cat /var/lib/docker/repositories-aufs | python -m json.tool

## change docker image installation directory
sudo docker ps -q | xargs docker kill
sudo service docker.io stop
mkdir /your/path/to/docker && chmod 700 /your/path/to/docker
sudo vim /etc/default/docker.io
# add new line
   DOCKER_OPTS="-g /your/path/to/docker"

## as root: su
chown root.root /your/path/to/docker
mv /var/lib/docker/* /your/path/to/docker/
echo "image location moved, see /etc/default/docker.io for new location" > /var/lib/docker/README

## as normal user
sudo service docker.io start
sudo docker images
## hellow-world listed

 

...78910...40...

 

如果你喜歡我的文章,請幫忙按 1-10次 LikeButton 化讚為賞,非常感謝!越喜歡當然可以越按越多 😛

熱門文章 Popular Posts

  • Install XPEnology (DSM) 5.1 on ESXi 6 (HP MicroServer Gen 8)
    Install XPEnology (DSM) 5.1 on ESXi 6 (HP MicroServer Gen 8) June 8, 2015
  • 呢幾日個blogger 有問題….
    呢幾日個blogger 有問題…. October 28, 2004
  • assembly
    assembly February 11, 2006
  • 新工作
    新工作 January 6, 2009
  • 失望
    失望 April 3, 2006

標籤雲 Tag Cloud

amazon CentOS chroot DD-WRT Debian Domino DSM DWA ebook ebook calibre ESXi GCP git google gradle groovy HTML5 IE Java Javascript javscript Jenkins LikeCoin Linux log LotusScript mint MySQL N36L nanoboot nginx PowerShell Qwiklabs responsive route Tomcat VMware vpn vSphere wordpress XPEnology 專欄 網絡資訊 選股 風帆

日曆 Calendar

December 2026
M T W T F S S
  « Feb    
 123456
78910111213
14151617181920
21222324252627
28293031  

Follow Me

Follow Us on RSSFollow Us on TwitterFollow Us on YouTube

文章存檔 Archives

Copyright © 2004-2021 hang321.net. All Rights Reserved