我正在使用PEAR 邮件。很多天都运行良好,我刚刚更改了重定向 URL,突然它无法正常工作。请看下面的代码。我通过 GET 和 SESSION 从另一个网站获取信息。它工作得很好,但是当我更改底部邮件中的重定向 URL 时,它就没有了。“发送”函数返回 true,但没有收到电子邮件。
<?php
session_start();
include("C:\Program Files (x86)\PHP\\v5.4\pear\Mail.php");
/* SMTP server name, port, user/passwd */
$smtpinfo["host"] = "mail.abc.com.com";
$smtpinfo["port"] = "25";
$smtpinfo["auth"] = true;
$smtpinfo["username"] = "support@abc.com";
$smtpinfo["password"] = "xxxxxxx";
/* Create the mail object using the Mail::factory method */
$mail_object =& Mail::factory("smtp", $smtpinfo);
$headers["From"] = "ABC Corp"."<support@abc.com>";
$headers["MIME-Version"] = "1.0";
$headers["Content-type"] = "text/html; charset=iso-8859-1";
/* mail setup recipients, subject etc */
if(isset($_GET['cdata']) && $_GET['ot']==3)
{
$mailmsg=urldecode($_GET['cdata']);
$headers["Subject"] = "New Contact Info";
$recipients = "aj@abc.com";
$headers["To"] = "aj@abc.com";
}
if($_GET['ot']==1)
{
$mailmsg = urldecode("<b>Purchase Information</b>: ".$_SESSION['proid']."<br /><br /><hr />Sender Information:<br />".$_GET['si']."<br /><hr />Receiver Information:<br />".$_GET['ri']);
$headers["Subject"] = "Order Information";
$se1=$_GET['se'];
$re1=$_GET['re'];
$recipients = $se1.",".$re1.",aj@abc.com";
$headers["To"] = $se1.",".$re1.",aj@abc.com";
}
if($_GET['ot']==2)
{
$mailmsg = urldecode("<b>Purchase Information</b>: <br />".$_SESSION['proid']."<br /><br /><hr /><b>Sender Information</b>:<br />".$_GET['si']."<br /><hr /><b>Receiver Information</b>: Same as above");
$headers["Subject"] = "Order Information";
$se1=$_GET['se'];
$recipients = $se1.",aj@abc.com";
$headers["To"] = $se1.",aj@abc.com";
}
/* Ok send mail */
$mail_object->send($recipients, $headers, $mailmsg);
header('Location:http://abc.com/cart.php?fin=1');
?> 我在底部添加了这段代码:
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
}
else
{
echo("<p>Message successfully sent!</p>");
}
它正在打印“其他”部分。
大编辑:现在它显示这条消息:
无法连接到 mail.abc.com:25 [SMTP:无法连接套接字:尝试以访问权限禁止的方式访问套接字。(代码:-1,响应:)]