Postfix

使用 gmail 在我自己的域中驗證電子郵件地址

  • December 11, 2015

我需要能夠使用 gmail 的 Web 界面發送電子郵件,但要讓它們看起來來自我自己的域,而不是來自 gmail 地址。為此,gmail 會詢問我的 smtp 伺服器的資訊(url、帳戶等)並繼續驗證,確實,我被允許使用我自己的 smtp 伺服器(postfix,託管在我的利諾德)。

Gmail 的響應是“您的其他電子郵件提供商響應速度太慢。請稍後再試,或聯繫您其他域的管理員以獲取更多資訊。” - 無法從他們那裡得到更多的細節。

我根據Linode 的 Centos 7 教程為 Centos 7設置 Postfix、Dovecot、MariaDB並嘗試適應我的需要,在 Chuan Ji 題為“使用 postfix 和 gmail 的自定義域電子郵件”的教程中找到了一些說明(即我根據那裡的建議生成了一個 .pem 文件,包括我的 smtp 伺服器的名稱作為通用名稱 - 證書中的 mail.tcs-usa.com 以使 gmail 滿意)。

我可以使用後綴作為我的 smtp 伺服器使用 Thunderbird 發送電子郵件,並且我已將後綴配置為將發送到我域中任何地址的傳入電子郵件轉發到我的 gmail 帳戶。這工作得很好。我還使用 mxtoolbox.com 檢查了我的 smtp 伺服器,它還按順序找到了所有內容。

我在下麵包含了 postfix 日誌的摘錄。唯一讓我想到的是第 11 行的“match_list_match: mail-yk0-f169.google.com: no match”和第 12 行的另一個。

如果我包含太多資訊,請提前感謝您的所有幫助和道歉,但我已經在這兩天了,但沒有得到任何地方。

亞歷克斯

以下是 /etc/postfix/main.cf 中的所有活動行:

command_directory = /usr/sbin

daemon_directory = /usr/libexec/postfix

data_directory = /var/lib/postfix

mail_owner = postfix

inet_interfaces = all

inet_protocols = all

mydestination = localhost, localhost.localdomain

alias_maps = hash:/etc/aliases

alias_database = hash:/etc/aliases

debug_peer_level = 2

#alexw- added google
debug_peer_list = google.com

debugger_command =
    PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
    ddd $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail.postfix

newaliases_path = /usr/bin/newaliases.postfix

mailq_path = /usr/bin/mailq.postfix

setgid_group = postdrop

readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
myhostname = mail.tcs-usa.com
mydomain = tcs-usa.com
myorigin = tcs-usa.com
#mynetworks = 127.0.0.0/8
message_size_limit = 30720000
virtual_alias_domains = 
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql-virtual_email2email.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
virtual_mailbox_base = /home/vmail
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
# alexw - removed permit_mynetworks from line below
smtpd_recipient_restrictions = permit_sasl_authenticated, reject_unauth_destination
smtpd_use_tls = yes
smtpd_tls_auth_only = yes
# The next 2 lines are the settings for using dovecot's ssl certificates:
# smtpd_tls_cert_file = /etc/pki/dovecot/certs/dovecot.pem
# smtpd_tls_key_file = /etc/pki/dovecot/private/dovecot.pem
# Replacing the above two lines with this one:
smtpd_tls_cert_file = /etc/postfix/tcs-usa.pem
virtual_create_maildirsize = yes
virtual_maildir_extended = yes
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1

以下是 master.cf 中的活動行:

#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       n       -       -       smtpd
#smtp      inet  n       -       n       -       1       postscreen
#smtpd     pass  -       -       n       -       -       smtpd
#dnsblog   unix  -       -       n       -       0       dnsblog
#tlsproxy  unix  -       -       n       -       0       tlsproxy
submission inet n       -       n       -       -       smtpd
 -o syslog_name=postfix/submission
 -o smtpd_tls_security_level=encrypt
 -o smtpd_sasl_auth_enable=yes
 -o smtpd_reject_unlisted_recipient=no
 -o smtpd_client_restrictions=$mua_client_restrictions
 -o smtpd_helo_restrictions=$mua_helo_restrictions
 -o smtpd_sender_restrictions=$mua_sender_restrictions
 -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
 -o milter_macro_daemon_name=ORIGINATING
 -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
 -o smtpd_tls_cert_file=/etc/postfix/tcs-usa.pem
# alexw - added the line above (smtpd_tls_cert_file)
smtps     inet  n       -       n       -       -       smtpd
 -o syslog_name=postfix/smtps
 -o smtpd_tls_wrappermode=yes
 -o smtpd_sasl_auth_enable=yes
 -o smtpd_reject_unlisted_recipient=no
 -o smtpd_client_restrictions=$mua_client_restrictions
 -o smtpd_helo_restrictions=$mua_helo_restrictions
 -o smtpd_sender_restrictions=$mua_sender_restrictions
 -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
 -o milter_macro_daemon_name=ORIGINATING
#628       inet  n       -       n       -       -       qmqpd
pickup    unix  n       -       n       60      1       pickup
cleanup   unix  n       -       n       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
#qmgr     unix  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       n       1000?   1       tlsmgr
rewrite   unix  -       -       n       -       -       trivial-rewrite
bounce    unix  -       -       n       -       0       bounce
defer     unix  -       -       n       -       0       bounce
trace     unix  -       -       n       -       0       bounce
verify    unix  -       -       n       -       1       verify
flush     unix  n       -       n       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       n       -       -       smtp
relay     unix  -       -       n       -       -       smtp
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
retry     unix  -       -       n       -       -       error
discard   unix  -       -       n       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
scache    unix  -       -       n       -       1       scache
dovecot   unix  -       n       n       -       -       pipe
   flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${recipient}

這是與 gmail 嘗試驗證我的 smtp 伺服器相關的日誌摘錄:

Dec  6 01:20:12 ewr postfix/submission/smtpd[13344]: connect from mail-yk0-f169.google.com[209.85.160.169]
Dec  6 01:20:12 ewr postfix/submission/smtpd[13344]: smtp_stream_setup: maxtime=300 enable_deadline=0
Dec  6 01:20:12 ewr postfix/submission/smtpd[13344]: match_hostname: mail-yk0-f169.google.com ~? 127.0.0.0/8
Dec  6 01:20:12 ewr postfix/submission/smtpd[13344]: match_hostaddr: 209.85.160.169 ~? 127.0.0.0/8
Dec  6 01:20:12 ewr postfix/submission/smtpd[13344]: match_hostname: mail-yk0-f169.google.com ~? 45.79.184.0/24
Dec  6 01:20:12 ewr postfix/submission/smtpd[13344]: match_hostaddr: 209.85.160.169 ~? 45.79.184.0/24
Dec  6 01:20:12 ewr postfix/submission/smtpd[13344]: match_hostname: mail-yk0-f169.google.com ~? [::1]/128
Dec  6 01:20:12 ewr postfix/submission/smtpd[13344]: match_hostaddr: 209.85.160.169 ~? [::1]/128
Dec  6 01:20:12 ewr postfix/submission/smtpd[13344]: match_hostname: mail-yk0-f169.google.com ~? [fe80::]/64
Dec  6 01:20:12 ewr postfix/submission/smtpd[13344]: match_hostaddr: 209.85.160.169 ~? [fe80::]/64
Dec  6 01:20:12 ewr postfix/submission/smtpd[13344]: match_list_match: mail-yk0-f169.google.com: no match
Dec  6 01:20:12 ewr postfix/submission/smtpd[13344]: match_list_match: 209.85.160.169: no match
Dec  6 01:20:12 ewr postfix/submission/smtpd[13344]: auto_clnt_open: connected to private/anvil
Dec  6 01:20:12 ewr postfix/submission/smtpd[13344]: event_enable_read: fd 18
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: send attr request = connect
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: send attr ident = submission:209.85.160.169
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: vstream_fflush_some: fd 18 flush 49
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: vstream_buf_get_ready: fd 18 got 25
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: private/anvil: wanted attribute: status
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: input attribute name: status
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: input attribute value: 0
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: private/anvil: wanted attribute: count
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: input attribute name: count
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: input attribute value: 1
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: private/anvil: wanted attribute: rate
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: input attribute name: rate
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: input attribute value: 1
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: private/anvil: wanted attribute: (list terminator)
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: input attribute name: (end)
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: > mail-yk0-f169.google.com[209.85.160.169]: 220 mail.tcs-usa.com ESMTP Postfix
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: watchdog_pat: 0x56163ce15080
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: vstream_fflush_some: fd 17 flush 36
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: smtp_get: EOF
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: match_hostname: mail-yk0-f169.google.com ~? 127.0.0.0/8
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: match_hostaddr: 209.85.160.169 ~? 127.0.0.0/8
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: match_hostname: mail-yk0-f169.google.com ~? 45.79.184.0/24
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: match_hostaddr: 209.85.160.169 ~? 45.79.184.0/24
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: match_hostname: mail-yk0-f169.google.com ~? [::1]/128
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: match_hostaddr: 209.85.160.169 ~? [::1]/128
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: match_hostname: mail-yk0-f169.google.com ~? [fe80::]/64
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: match_hostaddr: 209.85.160.169 ~? [fe80::]/64
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: match_list_match: mail-yk0-f169.google.com: no match
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: match_list_match: 209.85.160.169: no match
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: send attr request = disconnect
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: send attr ident = submission:209.85.160.169
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: vstream_fflush_some: fd 18 flush 52
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: vstream_buf_get_ready: fd 18 got 10
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: private/anvil: wanted attribute: status
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: input attribute name: status
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: input attribute value: 0
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: private/anvil: wanted attribute: (list terminator)
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: input attribute name: (end)
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: lost connection after CONNECT from mail-yk0-f169.google.com[209.85.160.169]
Dec  6 01:20:13 ewr postfix/submission/smtpd[13344]: disconnect from mail-yk0-f169.google.com[209.85.160.169]

正如所承諾的,我現在發布了一個解決方案,因為我找到了它:而不是使用伺服器 smtp.mydomain.com 的名稱,只要我使用伺服器的 IP 地址,問題就消失了。Google 能夠驗證,現在我可以從我的 gmail 帳戶發送電子郵件,而不會在 from: 或 sender: 欄位中顯示 gmail 或 google。

很可能,這與我的 dns 記錄的設置方式有關,但我想我會推遲嘗試弄清楚它現在正在工作。

在http://bit.ly/1NTmSqz找到解決方案

亞歷克斯

引用自:https://serverfault.com/questions/741142