如何配置 SMTP 客户端(Ubuntu 桌面)以使用 Gmail SMTP 服务器使用 postfix 从我的桌面发送电子邮件。
这就是我们登录公司提供的电子邮件的方式。我们使用 [email protected] 和密码登录到 gmail.com。所以我知道我们的电子邮件服务器是用 gmail 的。
我已将 postfix 配置为使用 smtp.gmail.server 发送电子邮件以从本地计算机发送电子邮件。我按照https://kifarunix.com/configure-postfix-to-use-gmail-smtp-on-ubuntu-18-04/设置后缀。然后尝试使用我的 gmail ([email protected]) 帐户和公司帐户 ([email protected]) 通过命令行发送电子邮件
echo "mail test"|mailx -s "Subject test" [email protected]
echo "mail test"|mailx -s "Subject test" [email protected]
后缀配置使用“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 中,当发送电子邮件至 [email protected] 时,会看到以下未送达通知。
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=<[email protected]>, 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 中,当电子邮件发送到 [email protected] 时,会看到以下未送达通知。
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=<[email protected]>, 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
发生的事情是您将邮件发送到本地服务器,但由于这些用户在本地不存在而失败。