linux – 如何为发件人地址配置真实域名

我尝试使用PHP mail()函数发送电子邮件,但它以某种方式失败,抱怨需要一个真正的域名.在maillog中观察到以下情况:

sendmail 4984 r25984: from=apache,size=273,class=0,nrcpts=1,
msgid=<201.r25@localhost.localdomain>,relay=apache@localhost
sendmail 4985 r25985: ruleset=check_mail,
arg1=,relay=mydomain.com [127.0.0.1],
reject=553 5.5.4 … Real domain name
required for sender address
sendmail 4984 r25984:
to=external@server.com,ctladdr=apache (48/48),delay=00:00:01,
xdelay=00:00:00,mailer=relay,pri=30273,relay=[127.0.0.1]
[127.0.0.1],dsn=5.6.0,stat=Data format error
sendmail 4984
r25984: r25984: DSN: Data format error

只要logrotate出现问题,cron就可以向external@server.com发送电子邮件.我不确定为什么PHP无法这样做.我尝试使用以下命令更改`sendmail.mc中的认配置:

MASQUERADE_AS(`mydomain.com')dnl
FEATURE(masquerade_envelope)dnl
FEATURE(masquerade_entire_domain)dnl
MASQUERADE_DOMAIN(localhost)dnl
MASQUERADE_DOMAIN(localhost.localdomain)dnl
MASQUERADE_DOMAIN(mycom)dnl

但是,它似乎没有任何影响.已经设置了PHP邮件功能中地址的标题.我还确保启用了SELinux httpd_can_sendmail.我还需要做些什么才能收到邮件

解决方法

我想我刚解决了.我在/ etc / hosts中有以下内容
127.0.0.1 www.mydomain.com test.mydomain.com
127.0.0.1 cdn.mycdn.com
127.0.0.1 localhost.localdomain localhost myserver.com

我需要的是将myserver.com放在localhost.localdomain的前面,以便sendmail认为它使用真实域发送电子邮件.

相关文章

1、安装Apache。 1)执行如下命令,安装Apache服务及其扩展包...
一、先说一下用ansible批量采集机器信息的实现办法: 1、先把...
安装配置 1. 安装vsftpd 检查是否安装了vsftpd # rpm -qa | ...
如何抑制stable_secret读取关键的“net.ipv6.conf.all.stabl...
1 删除0字节文件 find -type f -size 0 -exec rm -rf {} ...
## 步骤 1:安装必要的软件包 首先,需要确保系统已安装 `dh...