Linux sendmail“用户未知”错误-来自php表单的简单电子邮件

Linux sendmail“用户未知”错误-来自php表单的简单电子邮件

我已经设置了一个 ubuntu 网络服务器,需要能够通过 php 从表单发送电子邮件。该服务器托管多个网站,并且所有网站都存在此问题。

当我将表单发送到未托管在服务器上的域名(即 gmail、yahoo 等)时,电子邮件可以从表单发送而没有问题。

当我将表格发送到[电子邮件保护]托管在本地服务器上的邮件,我收到“用户未知”错误。这是因为我没有在服务器上创建帐户,但我不打算这样做...电子邮件托管在其他地方 [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])

正确的设置方法是什么?

谢谢。

答案1

在您的 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 配合使用,因此您可以使用邮件传输协议

答案2

如果您不关心实际使用哪个 MTA,我建议您安装 Postfix。它的配置相当简单,我在我的所有 Web 服务器以及为客户维护的邮件服务器上都使用它。

sudo apt-get install postfix

如果 Postfix 已经安装,则运行sudo dpkg-reconfigure postfix

按照菜单,选择“卫星系统”,保持默认设置,直到系统要求您输入 SMTP 中继主机,您将在其中输入允许您使用的 SMTP 主机。

您可能还必须输入以下内容/etc/postfix/main.cf

# Disable local delivery
mydestination =
local_recipient_maps =
local_transport = error:local mail delivery is disabled

答案3

虽然使用 postfix 可能是一个好主意,但这种问题也可能意味着你正在从黑名单 IP 发送电子邮件。许多 DHCP 分配的 ISP IP 都在黑名单中http://www.spamhaus.org/

如果你从 sendmail 发送电子邮件,它不会显示确切的错误,并且会一直发出烦人的User Unknown错误,除非你启用某些日志记录。但是,使用 postfix 会自动告诉你确切的问题,例如

从任何邮件服务器

Mail server said: 550 Blacklisted in zen.spamhaus.org: http://www.spamhaus.org/query/bl?

来自谷歌

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 来解决此问题。

高血压

相关内容