I had not any problems before, but i have checked today and i get the following error: Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting. I run my website on Heroku app. I use the latest version of php Mailer with google smtp servers. Are there any alternative smtp servers i can use? Here is my Script:
<?php
require 'PHPMailer-master/PHPMailerAutoload.php';
if(empty($_POST['Email'])){
$_POST['Email']= "";
}
if(empty($_POST['Name'])){
$_POST['Name']= "";
}
if(empty($_POST['Subject'])){
$_POST['Subject']= "";
}
if(empty($_POST['message'])){
$_POST['message']= "";
}
if (isset($_POST["message"]) && !empty($_POST["message"])) {
$mymail=smtpmailer("webdominar1@gmail.com",$_POST['Email'],
$_POST['Name'], $_POST['Subject'], $_POST['message']);
}else{
header('Location: http://webdominar.xyz'); exit();
}
function smtpmailer($to, $from, $from_name, $subject, $body) {
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = 'test@gmail.com';
$mail->Password = '1234';
$mail->SetFrom($from, $from_name);
$mail->Subject = "Webdominar Contact form ~Name: $from_name ~ subject: $subject
on http://webdominar.xyz ";
$mail->CharSet = 'UTF-8';
$mail->isHTML(true); // Set email format to HTML
$mail->Body = "blabla" ; //end body
$mail->AddAddress($to);
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Well done $from_name, your message has been sent!
We will reply to the following email: $from"
. "<br>Your Message: $body";
}
} //end function smtpmailer
?>