问题
I have the last version of phpMailer (v.5.4.2).
This code sends mail from localhost, using XAMPP, successfully, but on the remote server (000webhost) it doesn't work.
Nothing happens, there is no error message, but simply there is no mail in my inbox, spam or trash folder.
<?php
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Username = "qadenza@gmail.com";
$mail->Password = "mypass";
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->SetFrom('qadenza@gmail.com', 'Your Name');
$mail->Subject = "My subject";
$mail->Body = "My body";
$mail->AddAddress("qadenza@gmail.com", "Recipient name");
$mail->Send();
?>
回答1:
Have you contacted the hosting provider to check if they are blocking the outgoing ports or limiting sending through them?
来源:https://stackoverflow.com/questions/23859061/sending-mail-works-from-localhost-but-not-from-remote-server