我已经完成了编写 PHP 代码以便使用 POP3 发送电子邮件。但是每次我遇到错误时
[错误] => 连接到 POP3 服务器引发 PHP 警告:[errno] => 2 [errstr] => fsockopen() [function.fsockopen]: 无法连接到 pop3.yahoo.com:465(连接尝试failed ) SMTP -> ERROR: Failed to connect to server: 连接尝试失败,因为连接方在一段时间后没有正确响应,
这是我的代码。
<?php
require_once('/class.phpmailer.php');
require_once('/class.pop3.php'); // required for POP before SMTP
$pop = new POP3();
$pop->Authorise('pop3.yahoo.com',465,10, 'arsalansherwani@yahoo.com',
'******',1);
$mail = new PHPMailer();
$msg='Name';
//$body = file_get_contents('contents.html');
//$body = eregi_replace("[\]",'',$body);
$address='arsalanjawed619.com';
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->Host = 'pop3.yahoo.com';
$mail->SetFrom('arsalansherwani@yahoo.com', 'arsalan');
$mail->AddReplyTo("arsalansherwani@yahoo.com","arsalan");
$mail->Subject = "PHPMailer Test Subject via POP before SMTP, basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML($msg);
$address = "arsalanjawed619@yahoo.com";
$mail->AddAddress($address, "arsalan");
//$mail->AddAttachment("images/phpmailer.gif"); // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
任何帮助将不胜感激