开发者

Using PHP mail( )

I have a php mail script which works perfectly on a one host. However, when I attempt to use the same script on a network solutions host, the function returns true but no email ever sends.

//get mail function data
$case = $_POST['case'];
$to = addslashes(strip_tags($_POST['to']));
$message = addslashes(strip_tags($_POST['message']));
$subject = addslashes(strip_tags($_POST['sub开发者_StackOverflow社区ject']));
$message = addslashes(strip_tags($_POST['message']));
$from = "confirmation@website.co";
$headers = "From: $from\r\n";

//send email
        if (mail($to,$subject,$message,$headers)){
            //formatting for error message
            $emailSent = "block";
            $emailFailed = "none";
        }
        else //if the email fails to send
        {

            $emailSent = "none";
            $emailFailed = "block";
        }
?>

Does anyone know if different hosts require specific info in mail script?


This is a question for Network Solutions customer support. Sending mail from shared hosting servers is usually well locked down -- if they allow it at all, it's throttled. Also, calling mail just means the message was successfully passed to sendmail, not that the mail ever left the server. It could be sitting in a queue to be sent, it could have bounced for a million reasons beyond your control, etc.


Some hosts have this issue. On mine (Mosso), I had to adjust the last parameter (from) like so:

mail($to, $subject, $message, $headers, "-f".$from)

May not be the solution for NetSol but worth a try. I know some hosts disable the script and require using the smtp class to send mail.

This is assuming, of course, everything is correct with your DNS and MX records. If you're trying to send from an account that is different than the domain being sent from, some providers will automatically block that.


It maybe that they have not enabled php mail, but ask the host for specifics.

Looking at your code it is not cleaning the input sufficiently. take a look at the is_forbidden function here: http://thedemosite.co.uk/phpformmailer/source_code_php_form_mailer_more_secure_than_cgi_form_mailers.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜