我正在尝试使用 PEAR Mail 来使用外部 SMTP 服务器发送邮件。它似乎会卡住一段时间,然后脚本就结束了。它输出了所有的 "echo" 语句,直到发送后的那个语句。在 "before send" 的 echo 后面没有任何输出。有人能告诉我这里可能出了什么问题吗?(smtp 值用虚拟值替换)。邮件未被发送。谢谢你的帮助!
echo "start";
$n = $_POST['txtName'];
$e = $_POST['txtEmail'];
$t = 'Kenny <email@host.com>';
$f = 'Kenny <email@host.com>';
$s = 'CPA TEST';
$b = "name: $n email: $e";
include("mail.php");
echo "after include";
/* mail setup recipients, subject etc */
$recipients = $t;
$headers["From"] = $f;
$headers["To"] = $t;
$headers["Subject"] = $s;
$mailmsg = $b;
/* SMTP server name, port, user/passwd */
$smtpinfo["host"] = "my_smtp_host";
$smtpinfo["port"] = "25";
$smtpinfo["auth"] = true;
$smtpinfo["username"] = "my_email";
$smtpinfo["password"] = "my_password";
echo "before object";
/* Create the mail object using the Mail::factory method */
$mail_object =& Mail::factory("smtp", $smtpinfo);
echo "before send";
/* Ok send mail */
$send = $mail_object->send($recipients, $headers, $mailmsg);
echo "after send";
if (PEAR::isError($send)) { print($send->getMessage());}else{print "end";}
echo "done";
pear install Net_SMTP
即可完成安装,尽管如此,这对我仍然有所帮助! - LittleTreeXapt install php-net-smtp
。 - Tofandel