php mail function only working on local server and

2019-09-03 16:48发布

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

?>

2条回答
神经病院院长
2楼-- · 2019-09-03 16:57

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?

查看更多
成全新的幸福
3楼-- · 2019-09-03 17:21

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.

查看更多
登录 后发表回答