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

Shell
1
2
3
# /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)

Shell
1
2
3
# 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

Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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

Shell
1
# service postfix restart

5. Google 安全性設定

https://myaccount.google.com/security

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

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

寄信俾自己

Shell
1
2
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|電腦編程
Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## 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 化讚為賞,非常感謝!越喜歡當然可以越按越多 😛

搜尋 Search

簡介 Bio

香港人,現居南十字星空下。

為人貪心,科技、生活、財經、散文 皆有興趣,周身刀冇張利。

思想矛盾,喜歡現在work-life balance 既生活又懷念a city never sleep。

 

每月送我一杯咖啡支持我: liker.land/hang321




分類 Categories

  • 好文閱讀
  • 時事評論
  • 未分類
  • 生活記事
  • 科技資訊
  • 金融財經
  • 電腦編程
  • 音樂電影

文章存檔 Archives




熱門文章 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 27, 2006

標籤雲 Tag Cloud

CentOS Character chroot Cluster crash cryptography DD-WRT debug Domino DSM Dual Core DWA email ESXi GCP git google HylaFax IE Java Javascript JRE LikeCoin Linux log LotusScript mint MX MySQL nginx PKI PowerShell Qwiklabs srt telent VMware vpn vSphere WinXP wordpress XPEnology 專欄 網絡資訊 選股 風帆

日曆 Calendar

May 2025
M T W T F S S
  « Feb    
 1234
567891011
12131415161718
19202122232425
262728293031  

Follow Me

Follow Us on RSSFollow Us on TwitterFollow Us on YouTube

文章存檔 Archives

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