从本地主机发送邮件有效,但不能从远程服务器发送 [英] Sending mail works from localhost but not from remote server

查看:87
本文介绍了从本地主机发送邮件有效,但不能从远程服务器发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有最新版本的 phpMailer (v.5.4.2).

I have the last version of phpMailer (v.5.4.2).

此代码使用 XAMPP 从本地主机发送邮件成功,但在远程服务器 (000webhost) 上它不起作用.

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(); 
?>

推荐答案

您是否与托管服务提供商联系以检查他们是否阻止了传出端口或限制通过它们发送?

Have you contacted the hosting provider to check if they are blocking the outgoing ports or limiting sending through them?

这篇关于从本地主机发送邮件有效,但不能从远程服务器发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆