我尝试使用PHP mail()函数发送电子邮件,但它以某种方式失败,抱怨说,一个真正的域名是必需的。 以下是在maillog中观察到的:
sendmail 4984 r25984:from = apache,size = 273,class = 0,nrcpts = 1,msgid = <[email protected]>,relay = apache @ localhost
sendmail 4985 r25985:ruleset = check_mail,arg1 =,relay = mydomain.com [127.0.0.1],reject = 553 5.5.4 …发件人地址所需的真实域名
sendmail 4984 r25984:to = [email protected],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 =数据格式错误
sendmail 4984 r25984:r25984:DSN:数据格式错误
每当logrotate出现问题时,cron就能够发送电子邮件到[email protected]。 我不知道为什么PHP不能这样做。 我尝试使用以下命令对sendmail.mc中的默认configuration进行更改:
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邮件function的地址头已经被设置。 我也确保启用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就会认为它使用真正的域来发送电子邮件。
您必须在您的脚本中configuration您的电子邮件的标头,使其From: [email protected] 。
在你的sendmail.mc添加:
LOCAL_CONFIG Djmyserver.com
重新编译sendmail.cf ,重新启动sendmail,你应该可以