I am trying to send an email using phpmailer. This is the code that I have written.
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'shamir.towsif@gmail.com';
$mail->Password = '*********';
$mail->Port = 25;
$mail->From = 'shamir.towsif@gmail.com';
$mail->FromName = 'Shamir Towsif';
$mail->addAddress('shamir.towsif@gmail.com', 'Shamir Towsif');
$mail->addReplyTo('shamir.towsif@gmail.com', 'Information');
$mail->isHTML(true);
$mail->Subject = 'Here is the subject';
$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';
}
Here is the error that I am getting.
Message could not be sent. Mailer Error: SMTP connect() failed.
What am I doing wrong. The other questions in SO is not helping. Thanks in advance.