Let me preface this by saying that I am not trying to use gmail as my smtp server.
I am able to use PHPMailer to send emails to most all addresses from my host (hostgator) using my domains smtp server settings except for sending email to gmail addresses. Email sent to gmail addresses just never arrive. As far as I can tell, I am not getting any error messages.
What do I need to do? What is it that gmail is blocking so that people with gmail accounts cannot get email from some online email forms? What needs to be done to get around it?
Here is the code that I am using:
use PHPMailerPHPMailerPHPMailer;
use PHPMailerPHPMailerSMTP;
use PHPMailerPHPMailerException;
require "PHPMailer/src/PHPMailer.php";
require "PHPMailer/src/SMTP.php";
require "PHPMailer/src/Exception.php";
$mail = new PHPMailer(TRUE);
$mail->isSMTP();
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->SMTPAuth = true;
$mail->Host = "mail.mydomain.com";
$mail->Port = 465;
$mail->Username = "smtpusername";
$mail->Password = "smtppassword";
$mail->setFrom($FromEmail,$FromName);
$mail->addAddress("[email protected]","Fred");
$mail->addCC($FromEmail,$FromName);
$mail->addBCC("[email protected]","Webmaster");
$mail->Subject = "Email from contact form";
$mail->Body = $EmailMessage;
$mail->send();
$mail = null;