【发布时间】:2012-09-20 06:43:02
【问题描述】:
我收到此错误消息
警告:mail() [function.mail]:SMTP 服务器响应:550-请 在您的邮件客户端中打开 SMTP 身份验证,或登录到 550-IMAP/POP3 服务器在发送您的消息之前。 (sgs5.aws.lan) 550-[212.199.198.158]:7165 不允许通过此中继 服务器 550 没有身份验证。在 C:\程序 Files\Zend\Apache2\htdocs\PPC-Advert-System\Results\DebuggerFinalResultDB.php 在第 32 行。
代码可以在我的电脑上运行,但是当我把它放到另一台电脑上时它就不行了。我不知道配置中的问题在哪里。这是我设置 php.ini 要做的事情:
ini_set("SMTP","mail.me.com" );
ini_set("smtp_port","25" );
ini_set("auth_username","username" );
ini_set("auth_password","pass" );
然后我使用这个函数:
private function send_an_email($to,$file="",$message="") {
$subject = 'PCC-Advert-System';
$message = $message."<br/><br/><br/>Time Finished Scaning:<br/><br/><br/> ".date('l jS \of F Y h:i:s A')."\r\n Ratio: \r\n".$this->ratio." \r\nFile Path:<br/> <a href='http://212.199.198.158/PPC-Advert-System/FileStorage/$file'>http://212.199.198.158/PPC-Advert-System/FileStorage/$file</a><br/><br/><br/><a href='".$this->debug_file."'>$this->debug_file </a> ";//.$this->file;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers.= 'From: scriptspc@bso.com' . "\r\n" .
'Reply-To: scriptspc@bso.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
echo "<br/><br/><h1>Email has been sent</h1>";
}
【问题讨论】:
-
如果你想使用自定义的 SMTP,你应该使用类似
PHPMailer的东西,使用mail()和 SMTP 发送电子邮件是很困难的。 -
该解决方案有效..在我的电脑上..但在另一台电脑上却不行。我想查明问题。我对使用其他代码不感兴趣
-
好吧..phpmailer..似乎工作..谢谢
-
很高兴你做出了这个决定,简单的
mail()函数是一种痛苦和时间消耗。