google cloud platform

GCP + Cpanel + EXIM 4+ Sendgrid/Sendinblue to send Mail

有在用 google cloud platform 的人都知道,Google 強制將 smtp Port 25 封鎖了,所以 Cpanel 內建的 EXIM 無法正常的發信,就 Google 的官方文件中有建議幾家第三方的發信廠商,我今天選擇了 SendGrid 來測試。
一樣,一如往常,先看了 SendGrid 的官方文件 Exim 4 configuration for SendGrid – SendGrid Documentation | SendGrid , 發現設定還真是簡單,其實就只要 copy / past 就可以完成設定,但是….  總是有個但是,所以才會寫這篇 blog 來修正一個小地方和一個小提醒。
第一個小提醒:
很多人都不知道 Section: AUTH 中的最後一行帳號密碼是哪個

client_send = : YourSendGridUsername : YourSendGridPassword

其實就在 Account Details 這裡 看到的 USERNAME / PASSWORD .
另一個問題是 :
在 Section: PREROUTERS 當中官方的文件是寫

send_via_sendgrid:
driver = manualroute
domains = ! +local_domains
transport = sendgrid_smtp
route_list = “* smtp.sendgrid.net::587 byname”
host_find_failed = defer
no_more

但是這樣子會一直出現 smtp connection time out 無法工作,所以我再找了找文件,發現需要把 port 587 改成 port 2525

route_list = “* smtp.sendgrid.net::2525 byname”

OK, it is work !

Sendinblue 就只要以下三個地方新增相關的配置就可以直接套用

begin authenticators

sendinblue_login:
driver = plaintext
public_name = LOGIN
client_send = : 帳號:密碼

begin routers

send_via_sendinblue:
driver = manualroute
domains = ! +local_domains
transport = sendinblue_smtp
route_list = “* smtp-relay.sendinblue.com::587 byname”
host_find_failed = defer
no_more

begin transports

sendinblue_smtp:
driver = smtp
hosts = smtp-relay.sendinblue.com
hosts_require_auth = smtp-relay.sendinblue.com
hosts_require_tls = smtp-relay.sendinblue.com

About the Author

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料