Gmail, Exim and Let’s Encrypt

上個月 24 號發現不能在 Gmail 選擇用自己的 domain name 的 email 發電郵,發完後 Gmail 會回信報錯:

The response was:

TLS Negotiation failed, the certificate doesn't match the host. 

本以爲 SMTP server 哪裏設定不對,在網上發現不少人跟我一樣有同樣的經歷,原來最近 Google 已不再允許發電郵方使用 self-signed certificate,而我的 certificate 正正就是。由於 web server 一直有用 Let’s Encrypt 來生成 certificate,那就順手用 certbot 再多生成一張 certificate 給 Exim 用,詳細可參考 https://loune.net/2016/02/lets-encrypt-with-exim-and-dovecot/

主要的命令是:

$ certbot-auto certonly --standalone -d mail.example.com

由於 certbot 要用過 mail server 的 port 80 做 authentication,因此需要先把 web server 暫時停掉,每次 renew 也要,可以通過 certbot 的 –pre-hook 和 –post-hook 來做,例如:

$ certbot-auto renew --pre-hook "systemctl apache2 stop" --post-hook "systemctl apache2 start"


One thought on “Gmail, Exim and Let’s Encrypt”

Leave a Reply

Your email address will not be published.


seven − = 0

This site uses Akismet to reduce spam. Learn how your comment data is processed.