我有一个PHP 4代码,需要修改才能通过SMTP发送电子邮件,我已经在服务器上安装了Pear邮件包。它是Sevrer 2008 R2 64位。问题是它不发送任何电子邮件!我在这里缺少什么?Mail.php位于与实际网站文件不同的文件夹中,因此我必须在" Include"中指定路径。该文件的名称是Vistiro.php3:请建议:
Function PostSlip() {
Global $_parent,$_contact,$_problem,$_summary;
$p_contact = addslashes($_contact);
$p_problem = addslashes($_problem);
$p_summary = addslashes($_summary);
$p_now = time();
$qstring="insert into slips (spid,o_date,status,priority,o_tech,problem,summary,is_public,l_activity,l_tech,ctag) values ($_parent,$p_now,'O',4,'$p_contact','$p_problem','$p_summary','0','$p_now','$p_contact','ANONYMOUS')";
$qhandle = db_query($qstring);
$count = db_affected_rows($qhandle);
$newsid = db_insertid($qhandle);
RecalcSlip($_parent);
echo "<tr><td bgcolor=#808080 width=100% align=center>\n";
if ($count > 0) {
echo "Thank you for your submission.<br>";
echo "Your Slip ID is <b>$newsid</b><br>";
echo "Use this number at a later date to check on the status of this entry.";
include "/inetpub/PHP_New/PEAR/Mail.php";
$from = "username@domain.com";
$to = "username@domain.com";
$subject = "Test email using PHP SMTP with SSL\r\n\r\n";
$body = "This is a test email message";
$host = "smtp.companyname.com";
$port = "25";
$username = "domain\username";
$password = "email password";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
} else {
echo "An error occured during the update. Sorry, please try again later.";
}
echo "<br><a href=\"visitor.php3\">Return to Browsing</a>";
}