在 ubuntu 桌面上設置 smtp 客戶端以將 Gmail smtp 伺服器用於企業域
如何配置 SMTP 客戶端(Ubuntu 桌面)以使用 Gmail SMTP 伺服器使用 postfix 從我的桌面發送電子郵件。
這就是我們登錄公司提供的電子郵件的方式。我們使用 myemail@companydomain.com 和密碼登錄到 gmail.com。所以我知道我們的電子郵件伺服器是用 gmail 的。
我已將 postfix 配置為使用 smtp.gmail.server 發送電子郵件以從本地電腦發送電子郵件。我按照https://kifarunix.com/configure-postfix-to-use-gmail-smtp-on-ubuntu-18-04/設置後綴。然後嘗試使用我的 gmail (mygmail@gmail.com) 帳戶和公司帳戶 (myemail@companydomain.com) 通過命令行發送電子郵件
echo "mail test"|mailx -s "Subject test" myemail@gmail.com echo "mail test"|mailx -s "Subject test" myemail@compnaydomain.com
後綴配置使用“dpkg-reconfigure postfix”
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) biff = no append_dot_mydomain = no readme_directory = no compatibility_level = 2 smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination myhostname = ThinkPad-E470 alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = ThinkPad-E470, gmail.com, ThinkPad-E470, localhost.localdomain, localhost, companydomain.com relayhost = [smtp.gmail.com]:587 mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all inet_protocols = all smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_use_tls = yes smtpd_tls_auth_only = no smtpd_tls_key_file = /etc/ssl-certs/mail.companydomain.com.key smtpd_tls_cert_file = /etc/ssl-certs/mail.companydomain.com.crt smtpd_tls_CAfile = /etc/ssl-certs/cacert.pem tls_random_source = dev:/dev/urandom
在 /var/log/mail/log 中,當發送電子郵件至 myemail@gmail.com 時,會看到以下未送達通知。
May 7 13:41:58 ThinkPad-E470 postfix/pickup[6321]: 5962528214FB: uid=0 from=<root@ThinkPad-E470> May 7 13:41:58 ThinkPad-E470 postfix/cleanup[6695]: 5962528214FB: message-id=<20190507174158.5962528214FB@ThinkPad-E470> May 7 13:41:58 ThinkPad-E470 postfix/qmgr[6322]: 5962528214FB: from=<root@ThinkPad-E470>, size=375, nrcpt=1 (queue active) May 7 13:41:58 ThinkPad-E470 postfix/local[6697]: 5962528214FB: to=<myemail@companydomain.com>, relay=local, delay=0.38, delays=0.29/0.01/0/0.08, dsn=5.1.1, status=bounced (unknown user: "myemail") May 7 13:41:58 ThinkPad-E470 postfix/cleanup[6695]: A840828214FF: message-id=<20190507174158.A840828214FF@ThinkPad-E470> May 7 13:41:58 ThinkPad-E470 postfix/bounce[6698]: 5962528214FB: sender non-delivery notification: A840828214FF May 7 13:41:58 ThinkPad-E470 postfix/qmgr[6322]: A840828214FF: from=<>, size=2355, nrcpt=1 (queue active) May 7 13:41:58 ThinkPad-E470 postfix/local[6697]: A840828214FF: to=<root@ThinkPad-E470>, relay=local, delay=0.26, delays=0.21/0/0/0.05, dsn=2.0.0, status=sent (delivered to mailbox) May 7 13:41:58 ThinkPad-E470 postfix/qmgr[6322]: 5962528214FB: removed May 7 13:41:59 ThinkPad-E470 postfix/qmgr[6322]: A840828214FF: removed
在 /var/log/mail/log 中,當電子郵件發送到 myemail@companydomain.com 時,會看到以下未送達通知。
May 7 14:01:07 ThinkPad-E470 postfix/pickup[6321]: 798E828214FB: uid=0 from=<root@ThinkPad-E470> May 7 14:01:07 ThinkPad-E470 postfix/cleanup[6873]: 798E828214FB: message-id=<20190507180107.798E828214FB@ThinkPad-E470> May 7 14:01:07 ThinkPad-E470 postfix/qmgr[6322]: 798E828214FB: from=<root@ThinkPad-E470>, size=375, nrcpt=1 (queue active) May 7 14:01:07 ThinkPad-E470 postfix/local[6875]: 798E828214FB: to=<myemail@companydomain.com>, relay=local, delay=0.33, delays=0.24/0/0/0.09, dsn=5.1.1, status=bounced (unknown user: "myemail") May 7 14:01:07 ThinkPad-E470 postfix/cleanup[6873]: BDB3028214FF: message-id=<20190507180107.BDB3028214FF@ThinkPad-E470> May 7 14:01:07 ThinkPad-E470 postfix/bounce[6876]: 798E828214FB: sender non-delivery notification: BDB3028214FF May 7 14:01:07 ThinkPad-E470 postfix/qmgr[6322]: BDB3028214FF: from=<>, size=2355, nrcpt=1 (queue active) May 7 14:01:07 ThinkPad-E470 postfix/local[6875]: BDB3028214FF: to=<root@ThinkPad-E470>, relay=local, delay=0.23, delays=0.17/0/0/0.06, dsn=2.0.0, status=sent (delivered to mailbox) May 7 14:01:08 ThinkPad-E470 postfix/qmgr[6322]: 798E828214FB: removed May 7 14:01:08 ThinkPad-E470 postfix/qmgr[6322]: BDB3028214FF: removed
我不知道電子郵件、代理和中繼伺服器是如何工作的。我無法理解我的公司電子郵件伺服器是如何配置的,以及如何設置 postfix 以從我的台式機使用 gmail smtp 伺服器。
自簽名 ssl 密鑰和證書以及 CA 證書是為域 companydomain.com 在本地為後綴創建的。
如何配置 postfix 以從 ubuntu 客戶端使用我的 smtp 伺服器?
我認為問題在於
gmail.com
和companydomain.com
的存在mydestination
。在
mailx
命令中,最後一個參數是收件人地址。由於列出了這些域,mydestination
發生的事情是您將郵件發送到本地伺服器,但由於這些使用者在本地不存在而失敗。