我已经build立了一个Ubuntu的networking服务器,并且需要能够通过PHP从表单发送电子邮件。 服务器托pipe多个网站,这个问题依然存在。
当我有一个表单发送到服务器上没有托pipe的域名(即Gmail,雅虎等),电子邮件从表单发送没有问题。
当我将表单发送到本地服务器上托pipe的[email protected]时,我收到“用户未知”错误。 这是因为我没有在服务器上创build帐户,但我不打算…电子邮件托pipe在别处[gmail]。
这是我在/ var / mail / www-root中看到的一个例子…
The original message was received at Sun, 17 Oct 2010 18:39:41 -0700 from www-data@localhost ----- The following addresses had permanent fatal errors ----- [email protected] (reason: 550 5.1.1 <[email protected]>... User unknown) (expanded from: [email protected])
什么是正确的方式来设置?
谢谢。
在你的sendmail.mc中添加:
define(LUSER_RELAY,`mail.google.com')dnl
或者是Google告诉你使用的SMTP外发服务器。 根据你的Linux发行版产生sendmail.cf并重新启动sendmail(在Debian中这是通过运行sendmailconfig来完成的)。
编辑:如果机器不接受任何传入的电子邮件,它可能会更好地安装nullmailer:
# apt-get install nullmailer # dpkg-reconfigure nullmailer
编辑:由于nullmailer不能使用Gmail,你可以使用ssmtp
如果你不关心你实际使用的MTA,我推荐安装Postfix。 configuration起来相当简单,我在我的所有Web服务器以及我为客户维护的邮件服务器上都使用它。
sudo apt-get install postfix
如果已经安装了Postfix,那么运行sudo dpkg-reconfigure postfix
按照菜单,select“卫星系统”,坚持默认设置,直到您被要求input您允许使用的SMTP主机的SMTP中继主机。
您可能还必须将以下内容放在/etc/postfix/main.cf
# Disable local delivery mydestination = local_recipient_maps = local_transport = error:local mail delivery is disabled
虽然得到后缀可能是一个好主意,但这种问题也可能意味着你正在从黑名单IP发送电子邮件。 许多DHCP分配的ISP IP位于http://www.spamhaus.org/的黑名单中。
如果您从sendmail发送电子邮件,它将不会显示确切的错误,并继续咆哮恼人的User Unknown错误,除非你启用一些日志logging。 但是,用postfix会自动告诉你确切的问题,比如
从任何邮件服务器
Mail server said: 550 Blacklisted in zen.spamhaus.org: http://www.spamhaus.org/query/bl?
来自Google
status=bounced (host gmail-smtp-in.l.google.com[74.125.142.27] said: 550-5.7.1 [IP] The IP you're using to send mail is not authorized to 550-5.7.1 send email directly to our servers. Please use the SMTP relay at your 550-5.7.1 service provider instead. Learn more at 550 5.7.1 http://support.google.com/mail/bin/answer.py?a
从Hotmail
status=bounced (host mx4.hotmail.com[65.55.37.120] said: 550 DY-001 (COL0-MC4-F9) Unfortunately, messages from <IP> weren't sent. Please contact your Internet service provider. You can tell them that Hotmail does not relay dynamically-assigned IP ranges. You can also refer your provider to http://mail.live.com/mail/troubleshooting.aspx#errors.
如果您使用自己的自定义邮件服务器,您可以修复它,否则你需要让ISP来解决这个问题。
HTH