PHP邮件功能仅在本地服务器上起作用,而在远程服务器上不起作用 [英] php mail function only working on local server and not on remote server

查看:104
本文介绍了PHP邮件功能仅在本地服务器上起作用,而在远程服务器上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就像标题一样,我用HTML创建了一个简单的表单

just as the title I created a simple form in HTML

您可以在 http://thee-l.comuv.com/send.php上看到它这会向我发送一封电子邮件,其中包含指定的主题和正文,我是在Apache上的localhost上运行的,不到一分钟就进入了收件箱,但随后将其上传到该站点的远程服务器上,但没有给我发电子邮件

you can see it at http://thee-l.comuv.com/send.php this sends an email to me with the subject and body text specified I run this on localhost from Apache and I get in my inbox in less than a minute but I then upload it to the remote server the site and it does not email me at all

我有一个gmail地址,所以为了方便起见,我使用smtp2go制作了一个传出的smtp服务器,这是我发送的第一个php发送的电子邮件,我非常高兴,并立即将其放在远程服务器上,我们在这里

I have a gmail address so to make it easy I made an outgoing smtp server with smtp2go this was my first php-sent email, I was really happy and right away put it on the remote server and here we are

我正在使用000webhost

I am using 000webhost

这是我的代码

<?php
if ($_POST['submit']){
ini_set("SMTP", "smtp2go.com");
ini_set("smtp_port", 2525);
$to = "lsworkemail112@gmail.com";
$subj = $_POST['topic'];
$body = $_POST['message'];
$header = "From: lsworkemail112@gmail.com";
if (mail($to, $subj, $body, $header))
{
echo "Message sent successfully";
}
else
{
echo "Message sent unsuccessfully";
}
}
else
{
echo "<html>
<form method=\"post\" action=\"send.php\">
Topic: <br/><input type=\"text\" name=\"topic\"/><br/>
Message: <br/><textarea name=\"message\"></textarea><br/>
<input type=\"submit\" value=\"Send\" name=\"submit\"/>
</form>
</html>";
}

?>

推荐答案

我尝试单击您的链接,但显然您的网站正在接受审核(可能由于您的测试而邮寄过多/怀疑为垃圾邮件?).即使这样,链接到.php页面也不会向我们显示代码,因为服务器将执行该代码并将结果仅发送到浏览器.最好将代码复制/粘贴到问题中.

I tried clicking on your link, but apparently your website is under review (possibly for mailing too much/suspected of spamming because of your testing?). Even then, linking to a .php page won't show us the code, since the server will execute it and send just the result to the browser. It's better if you copy/paste your code into the question.

此外,正如@Computerish所说,您可能刚刚遇到主机限制.您今天运行了多少次mail()代码?

Also, as @Computerish said, you may have just run into a limit on your host. How many times have you run your mail() code today?

这篇关于PHP邮件功能仅在本地服务器上起作用,而在远程服务器上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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