0

I got this error

Message could not be sent. Mailer Error: SMTP connect() failed.https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

$mail = new PHPMailer;
$mail->IsSMTP();                                   
$mail->Host = 'smtp.gmail.com';                    
$mail->SMTPAuth = true;                            
$mail->Username = '*****';         
$mail->Password = '*****';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->SetFrom('*****', 'Innovatory');
$mail->AddAddress($f1_email);
$mail->isHTML(true);
$bodyContent = '<br><h3>From: '.$f1_fname.'</h3>';
$bodyContent .= '<b>Company Name: '.$f1_subject.'<br>Mobile: '.$f1_phone.'<br>Email: '.$f1_email.'</b><br><br><b>Service:</b> '.$f1_message;

$mail->Subject = 'Contact Email';
$mail->Body    = $bodyContent;
$mail->mailer="smtp";
if(!$mail->send())
{
    echo 'Message could not be sent. ';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else 
{
    ?>
    <script>
    alert('Mail has been sent.');
    window.location.href='index.php';
    </script>
    <?php
}
Alex Howansky
  • 50,515
  • 8
  • 78
  • 98
  • Aaaaand you just posted your email and password on the Internet... I'm hoping that password you pasted was an obfuscation. Otherwise, you need to change it immediately. – Alex Howansky May 04 '17 at 14:58
  • Possible duplicate of [send email using Gmail SMTP server through PHP Mailer](http://stackoverflow.com/questions/16048347/send-email-using-gmail-smtp-server-through-php-mailer) – Pedro Lobito May 04 '17 at 14:59
  • And @AlexHowansky did mean you should change the password NOW, as most of us can look back through the edits and see what it was before he edited the question for you – RiggsFolly May 04 '17 at 15:21
  • i have another problem also when user click on submit btn of contact form at that time whatever email is entered by user that user receive the mail. – Satyam Dhameliya May 05 '17 at 13:57

0 Answers0