Reputation:
i am getting this error kindly help me
2015-03-06 10:43:16 SMTP ERROR: Failed to connect to server: No connection could be made because the target machine actively refused it. (10061) 2015-03-06 10:43:16 SMTP connect() failed. Message could not be sent.Mailer Error: SMTP connect() failed.
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 = '[email protected]';
$mail->FromName = 'usman';
$mail->addAddress('[email protected]', 'usmanxxx'); // Add a recipient
$mail->addAddress('[email protected]'); // Name is optional
$mail->addReplyTo('[email protected]', 'Information');
$mail->addCC('[email protected]');
$mail->addBCC('[email protected]');
//$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';
}
Upvotes: 1
Views: 8071
Reputation: 326
some while ago I also encountered this problem. The server admin is also not very helpful, but from what i have already done, this is the thing that must be checked :
Please correct me if i'm wrong.
Upvotes: 2