Php

Postfix + php 將發送到本地域的電子郵件地址轉換為 something@localhost.localdomain

  • May 23, 2015

我在這裡的第一個問題,如果我沒有立即提供足夠的資訊,請不要對我投反對票;-)

我正在使用 OpenVZ 執行由 afterburst.com 託管的 VPS

我成功安裝並配置了以下組件:

zpanel (with apache, mysql, php5.3, postfix)
updated successfully to php5.4
running Laravel on secundary webpage (works fine)

使用 php 和 MUA 發送電子郵件都可以正常工作。從 MUA 發送到本地託管域的電子郵件也可以正常工作。

但這是錯誤:

當我使用 php sendmail 命令向本地託管域發送電子郵件時,電子郵件地址將轉換為 something@localhost.localdomain。我相信這與我的 DNS 設置有關,但我嘗試了很多方法,但找不到正確的答案

我的主機名是

[user@vps ~]# hostname
vps.krause-it-consulting.com

這是我的後綴配置(postconf -n):

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
debug_peer_level = 2
delay_warning_time = 4
disable_vrfy_command = yes
html_directory = no
inet_interfaces = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = vps.$mydomain
mydomain = krause-it-consulting.com
myhostname = vps.krause-it-consulting.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 VPS_IP
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.2.2/README_FILES
recipient_delimiter = +
relay_domains = proxy:mysql:/etc/zpanel/configs/postfix/mysql-relay_domains_maps                                                                                                                                                      .cf
sample_directory = /usr/share/doc/postfix-2.2.2/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_host_lookup = dns, native
smtp_use_tls = no
smtpd_client_restrictions =
smtpd_data_restrictions = reject_unauth_pipelining
smtpd_helo_required = yes
smtpd_helo_restrictions =
smtpd_recipient_restrictions = permit_sasl_authenticated,        permit_mynetwor                                                                                                                                                      ks,        reject_unauth_destination,        reject_non_fqdn_recipient,        r                                                                                                                                                      eject_unknown_recipient_domain
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sender_restrictions =
smtpd_use_tls = no
soft_bounce = yes
transport_maps = hash:/etc/postfix/transport
unknown_local_recipient_reject_code = 550
virtual_alias_maps = proxy:mysql:/etc/zpanel/configs/postfix/mysql-virtual_alias                                                                                                                                                      _maps.cf,                     regexp:/etc/zpanel/configs/postfix/virtual_regexp
virtual_gid_maps = static:12
virtual_mailbox_base = /var/zpanel/vmail
virtual_mailbox_domains = proxy:mysql:/etc/zpanel/configs/postfix/mysql-virtual_                                                                                                                                                      domains_maps.cf
virtual_mailbox_maps = proxy:mysql:/etc/zpanel/configs/postfix/mysql-virtual_mai                                                                                                                                                      lbox_maps.cf
virtual_minimum_uid = 101
virtual_transport = dovecot
virtual_uid_maps = static:101

如果您需要更多資訊,請詢問,我會添加。

最後我想強調一下,這裡只有通過 php 和 sendmail 命令發送的電子郵件才是問題所在。其他一切正常(到目前為止:-))

考慮到過去兩週我一直在研究這個問題,在寫下這個問題的細節之後,我終於能夠解決它。

這實際上是我在 hosts 文件中創建的一個條目導致了這個問題。也許我玩得太多了:-)

無論如何,這是問題行:

127.0.0.1 localhost.localdomain localhost vps.krause-it-consulting.com krause-it-consulting.com hobbyathletes.com

刪除我的託管域的 2 個添加後,它起作用了: 正確的行:

127.0.0.1 localhost.localdomain localhost vps.krause-it-consulting.com 

無論如何,我希望這會對​​某人有所幫助。

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