如何配置 SMTP 客户端(Ubuntu 桌面)以使用 Gmail SMTP 服务器通过 postfix 从我的桌面发送电子邮件。
这就是我们登录公司提供的电子邮件的方式。我们使用以下方式登录 gmail.com[电子邮件保护]和密码。所以我理解我们的电子邮件服务器是 Gmail。
我已将 postfix 配置为使用 smtp.gmail.server 从本地计算机发送电子邮件。我遵循https://kifarunix.com/configure-postfix-to-use-gmail-smtp-on-ubuntu-18-04/设置 postfix。然后尝试使用我的 gmail 通过命令行发送电子邮件([电子邮件保护])帐户及公司帐户([电子邮件保护])
echo "mail test"|mailx -s "Subject test" [email protected]
echo "mail test"|mailx -s "Subject test" [email protected]
使用“dpkg-reconfigure postfix”进行 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 中,当电子邮件发送至[电子邮件保护]。
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 中,当电子邮件发送至[电子邮件保护]。
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 服务器。
为域 companydomain.com 的 Postfix 本地创建自签名 SSL 密钥和证书以及 CA 证书。
如何配置 postfix 以从 ubuntu 客户端使用我的 smtp 服务器?
答案1
我认为问题在于gmail.com
和 的companydomain.com
存在mydestination
。
在mailx
命令中,最后一个参数是收件人地址。由于这些域已列出,mydestination
因此您将邮件发送到本地服务器,但由于本地不存在这些用户,因此发送失败。