【发布时间】:2012-02-05 10:35:49
【问题描述】:
我正在尝试将邮件发送到我的本地邮件服务器。我正在使用 hMailServer 作为邮件服务器,我已经按照此处所述进行了配置:
Setting up local Mail (SMTP, POP3, IMAP) Server on XAMPP
但是当我尝试发送邮件时,我收到了这个错误:
( ! ) 警告:mail() [function.mail]: SMTP 服务器响应:550 地址无效。在 C:\wamp\www\kariyersitem\register.php 上线 161
邮件服务器的日志文件显示此错误如下:
"DEBUG" 3108 "2012-01-08 18:04:24.447" "Creating session 14"
"SMTPD" 3108 14 "2012-01-08 18:04:24.448" "127.0.0.1" "SENT: 220 localhost ESMTP"
"SMTPD" 1728 14 "2012-01-08 18:04:24.454" "127.0.0.1" "RECEIVED: HELO olcay-pc"
"SMTPD" 1728 14 "2012-01-08 18:04:24.455" "127.0.0.1" "SENT: 250 Hello."
"SMTPD" 3108 14 "2012-01-08 18:04:24.457" "127.0.0.1" "RECEIVED: MAIL FROM:<you@yourdomain>"
"SMTPD" 3108 14 "2012-01-08 18:04:24.458" "127.0.0.1" "SENT: 550 The address is not valid."
"SMTPD" 2040 14 "2012-01-08 18:04:24.459" "127.0.0.1" "RECEIVED: QUIT"
"SMTPD" 2040 14 "2012-01-08 18:04:24.460" "127.0.0.1" "SENT: 221 goodbye"
"DEBUG" 3392 "2012-01-08 18:04:24.461" "Closing TCP/IP socket"
"DEBUG" 3392 "2012-01-08 18:04:24.462" "Ending session 14"
我已经检查了地址,我确定它是正确的。
谁能告诉我是什么问题?
这是我的邮件代码:
$to = $frm_kadi;
$subject = $site_title.' Üyelik Aktivasyonu';
$message = 'hello';
$headers = 'From: '.$contact."\r\n".'Reply-To: '.$contact."\r\n".'X-Mailer: PHP/'.phpversion();
$mresult = mail($to, $subject, $message, $headers);
我检查了$contact,它在我的config.php 文件中写为olcayertas@gmail.com。在发送邮件之前,我已经使用 echo 函数来调试我的代码,它是正确的。
目前我的 $contact 变量设置为:
$contact = "olcayertas@gmail.com";
更新 1
按照@Jared Farrish 的建议,将php.ini 中的sendmail_from 设置为olcayertas@gmail.com 解决了第一个问题。但是现在我有一个新问题:
"DEBUG" 3108 "2012-01-08 22:15:28.497" "Creating session 24"
"SMTPD" 3108 24 "2012-01-08 22:15:28.498" "127.0.0.1" "SENT: 220 localhost ESMTP"
"SMTPD" 3108 24 "2012-01-08 22:15:28.499" "127.0.0.1" "RECEIVED: HELO olcay-pc"
"SMTPD" 3108 24 "2012-01-08 22:15:28.500" "127.0.0.1" "SENT: 250 Hello."
"SMTPD" 4380 24 "2012-01-08 22:15:28.511" "127.0.0.1" "RECEIVED: MAIL FROM:<olcayertas@gmail.com>"
"DEBUG" 4380 "2012-01-08 22:15:28.542" "Total spam score: 0"
"SMTPD" 4380 24 "2012-01-08 22:15:28.547" "127.0.0.1" "SENT: 250 OK"
"SMTPD" 3108 24 "2012-01-08 22:15:28.548" "127.0.0.1" "RECEIVED: RCPT TO:<olcayertas>"
"SMTPD" 3108 24 "2012-01-08 22:15:28.548" "127.0.0.1" "SENT: 550 A valid address is required."
"SMTPD" 2040 24 "2012-01-08 22:15:28.552" "127.0.0.1" "RECEIVED: QUIT"
"DEBUG" 2040 "2012-01-08 22:15:28.552" "Deleting message file"
"SMTPD" 2040 24 "2012-01-08 22:15:28.552" "127.0.0.1" "SENT: 221 goodbye"
"DEBUG" 4380 "2012-01-08 22:15:28.555" "Closing TCP/IP socket"
"DEBUG" 4380 "2012-01-08 22:15:28.556" "Ending session 24"
它似乎没有完全获得目标地址。我正在尝试向自己发送邮件,但它只收到用户名 olcayertas 和缺少域 @gmail.com。
更新 2
我已经解决了第二个问题。这是我的错。
更新 3
现在我收到此错误:
"SENT: 530 SMTP authentication is required."
但是我已经在Settings->Ptotocols->SMTP->Delivery of e-mail->SMTP Relayer下填写了SMTP认证设置。 Server requires authentication 和 Use SSL 选项已检查。
更新 4
禁用Settings->Advanced->IP Ranges->My Compter中hMailServer的Require SMPTP authentication选项解决了SMTP认证问题。
【问题讨论】:
-
请告诉我们
mail()的参数是什么。 -
+1 用于实际查看 PHP 相关问题的错误日志。
-
您使用的实际 SMTP 设置(在合理范围内)是什么?
-
什么是
$contact?这是给你的问题,而不是$to(至少根据hMailServer docs)。
标签: php email local mail-server