Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从web表单发送信息_Php_Forms_Smtp - Fatal编程技术网

Php 从web表单发送信息

Php 从web表单发送信息,php,forms,smtp,Php,Forms,Smtp,我试图通过网络表单发送电子邮件,但我遇到了一个错误。。。。。。 我在WindowsServer2008R2(64位)拆分服务器(2服务器环境)上配置了php环境,其中一台服务器运行mysql,另一台服务器运行php和apache(使用xammp安装)。我在运行网站时遇到以下错误: 警告:mail()[function.mail]:无法在“localhost”端口25连接到mailserver,请验证php.ini中的“SMTP”和“SMTP_端口”设置,或在线使用C:\xampp\htdocs\

我试图通过网络表单发送电子邮件,但我遇到了一个错误。。。。。。 我在WindowsServer2008R2(64位)拆分服务器(2服务器环境)上配置了php环境,其中一台服务器运行mysql,另一台服务器运行php和apache(使用xammp安装)。我在运行网站时遇到以下错误:

警告:mail()[function.mail]:无法在“localhost”端口25连接到mailserver,请验证php.ini中的“SMTP”和“SMTP_端口”设置,或在线使用C:\xampp\htdocs\contact.php中的ini_set()

以下是php脚本:

if(empty($_POST) === false)
    {
        //Array to store and output errors
        $errors = array();

        $name = $_POST['name'];
        $email = $_POST['email'];
        $subject = $_POST['subject'];
        $feedback = $_POST['feedback'];

        //check if the all the required fields have been completed
        if(empty($name)=== true || empty($email)=== true || empty($subject)=== true || empty($feedback) === true)
            {
                $errors[] = 'Name, email, subject and message are required';
            }
        else
            {
                //check if the email is valid
                if(filter_var($email,FILTER_VALIDATE_EMAIL) === false )
                    {
                        $errors[] = 'That\'s not a valid email address';
                    }
                //check if the name contains any numbers
                if (ctype_alpha($name)=== false)
                    {
                        $errors[] = 'Name must only contain letters';
                    }
            }

    }

    //if there are no errors then send the email
    if(empty($errors) === true)
        {
            //send email
            mail('erecruitment@saqa.co.za','$subject','$feedback','FROM:'.'$email');

            //redirect users
            header('Location: contact.php?sent');
            //exit();
        }
以下内容来自php.ini文件:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25




; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com

我还在学习php,如果有人能帮我看看我做错了什么,那就太好了

你在本地机器上运行sendmail服务器了吗?你可以得到它


出于测试目的,您可以使用。它将模拟发送电子邮件。

尝试更改您的SMTP主机和端口不使用localhost您无法在localhost上发送邮件尝试在您的live server/SiteThank@Rakeshharma上发送邮件我将尝试更改托管php和apache的服务器上的SMTP主机和端口号,但我仍然收到相同的错误。我是否需要指定服务器名称和smtp地址。i、 e SMTP=172.x.x.x/mail.boom.com?谢谢@nord_ua。我下载了它,只需要让服务器上的互联网,然后我会反馈给你