Sending mail works from localhost but not from remote server

爱⌒轻易说出口 提交于 2019-12-25 12:48:10

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!