I'm trying to use PHPMailer to send emails from a contact form. Once submitted, the server doesn't respond for more than 5 minutes, then results in ERROR 405 Not Allowed - ngnix
.
I'm using SMTP Auth from webmaster@mydomain.com, and the SMTP server is located at voyager.websitewelcome.com. I thought, "Could it be because of the cross-domain submission, even though this isn't AJAX and is all PHP?"
Nope, see answer below:
mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'voyager.websitewelcome.com';
$mail->SMTPAuth = true;
$mail->Username = 'webmaster@mydomain.com';
$mail->Password = 'mypassword';
$mail->SMTPSecure = 'tls'; //<---- THIS is the problem
$mail->Port = 465;
$mail->setFrom('webmaster@mydomain', 'My Company Kiosk');
$mail->addAddress('me@mydomain.com', 'My Name');
$mail->isHTML(true);
$mail->Subject = 'New Lead from My Company';
$mail->Body = '<b>test</b> html'; //$body;
$mail->AltBody = 'test text';
try {
$mail->send();
//echo $output;
}
catch (phpmailerException $e) {
echo $e->errorMessage();
} catch (Exception $e) {
$e->getMessage();
}