我收到此错误,请帮助我
2015-03-06 10:43:16 SMTP错误:无法连接到服务器:否 可以建立连接,因为目标机器主动拒绝 它。 (10061)2015-03-06 10:43:16 SMTP connect()失败。消息可以 不发送.Mailer错误:SMTP连接()失败。
my code is
<?php
require 'classes/class.phpmailer.php';
require 'classes/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 1; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'localhost'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'root'; // SMTP username
$mail->Password = ''; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->From = 'bces11-51@xxxxxx.edu.pk';
$mail->FromName = 'usman';
$mail->addAddress('usmanxxxx@yahoo.com', 'usmanxxx'); // Add a recipient
$mail->addAddress('usmanxxxxx@gmail.com'); // Name is optional
$mail->addReplyTo('info@example.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'subject is send email';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
答案 0 :(得分:1)
如果我错了,请纠正我。