php mail function only working on local server and not on remote server

我是研究僧i 提交于 2019-12-12 01:27:22

问题


just as the title I created a simple form in HTML

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

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

I am using 000webhost

here is my code

<?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>";
}

?>

回答1:


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.

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?




回答2:


Check your web hosting company's policies about outgoing mail. There may be a daily limit, a outright ban on it, or it may be an extra service you have to ask for. Almost all hosting companies do something to limit the use of the send() function to prevent spammers from taking advantage of their servers.



来源:https://stackoverflow.com/questions/4425557/php-mail-function-only-working-on-local-server-and-not-on-remote-server

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