发送具有不同域名的电子邮件

While sending the mail it showing

Mailer Error: SMTP connect() failed

It was not working properly.Please check the code and give me valuable answer.

require 'PHPMailerAutoload.php';
if(isset($_POST['send']))
{
$email = $_POST['email'];
$password = $_POST['password'];
$to_id = $_POST['toid'];
$message = $_POST['message'];
$subject = $_POST['subject'];
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.domain.com';
$mail->Port =  465;
$mail->SMTPSecure = 'ssl';
$mail->SMTPAuth = true;
$mail->Username = $email;
$mail->Password = $password;
$mail->addAddress($to_id);
$mail->Subject = $subject;
$mail->msgHTML($message);
var_dump($mail->send());
if (!$mail->send()) {
$error = "Mailer Error: " . $mail->ErrorInfo;
echo '<p id="para">'.$error.'</p>';
}
else {
echo '<p id="para">Successfully sent mail</p>';
}
}

?>

It looks like an authentication problem. control your host, port, username and password.