简体   繁体   English

联系表格出现PHP错误

[英]PHP error with contact form

I am currently creating a contact form and with the help of thw world wide web I made a php background, which I also understand. 我目前正在创建联系表格,并在万维网的帮助下制作了php背景,我也知道。

Unfortunately it looks al great to me, but I do get aan error, saying: 不幸的是,这对我来说很棒,但是我确实收到一个错误,说:

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\\wamp\\www\\jquery\\mail.php on line 16 [line 16 is the place where the if statement with the mail and the attributes appaeat, see below] 警告:mail():无法通过“ localhost”端口25连接到邮件服务器,无法验证php.ini中的“ SMTP”和“ smtp_port”设置,或在C:\\ wamp \\ www \\ jquery \\ mail.php中使用ini_set()第16行[第16行是带有邮件和属性appaeat的if语句的位置,请参见下文]

I have honestly no clue what the error means, and my code is below, does anybody now what it means and how I could fix it? 老实说,我不知道该错误意味着什么,并且我的代码在下面,现在有人知道它的含义是什么,我该如何解决? Thanks in advance! 提前致谢!

<?php
 $name = $_POST['name'];
 $email = $_POST['email'];
 $city = $_POST['city'];
 $message = $_POST['message'];
 $from = 'From: timohoogie'; 
 $to = 'ownemail@gmail.com'; 
 $subject = 'Contact zoeken met whoduniit';
 $human = $_POST['human'];

 $body = "From: $name\n E-Mail: $email\n City: $city\n Message:\n $message";

 if ($_POST['submit'] && $human == '4') {                
     if (mail ($to, $subject, $body, $from)) { 
    echo '<p>Your message has been sent!</p>';
    } else { 
    echo '<p>Something went wrong, go back and try again!</p>'; 
} 
} else if ($_POST['submit'] && $human != '4') {
echo '<p>You answered the anti-spam question incorrectly!</p>';
}

?> ?>

<form method="post" action="mail.php">
            <label for="Name">Naam:</label>
            <input type="text" name="name" id="name" />

            <label for="City">Stad:</label>
            <input type="text" name="city" id="city" />




            <label for="email">Email:</label>
            <input type="text" name="email" id="email" />

            <label for="gevonden"> Hoe heeft u ons gevonden</label>
            <input type="text" name="gevonden" id="gevonden" />

                <br>
                <br>

            <label for="Message">Bericht:</label><br />
            <textarea name="message" rows="20" cols="20" id="message"></textarea>

            <label>*What is 2+2? (Anti-spam)</label>
            <input name="human" placeholder="Type Here">

            <input type="submit" name="submit" value="Submit" class="submit-button" />
        </form>

mail is a PHP function, yes. mail是一个PHP函数,是的。 But it must be installed on the server that is doing the actual sending. 但是必须将其安装在进行实际发送的服务器上。 SMTP is a slightly different protocol that seems to be getting triggered because the simple mail function is failing (for it not being installed.) SMTP是一个略有不同的协议,由于简单的邮件功能失败(未安装,因此似乎已被触发)。

You need to check with your service provider to see what mail function you should be using. 您需要与服务提供商联系,以查看应使用的邮件功能。

You need to have a SMTP server running on the machine that hosts this code with your current settings. 您需要在托管此代码和当前设置的计算机上运行SMTP服务器。 Or else you need to change the SMTP settings in your php.ini file. 否则,您需要在php.ini文件中更改SMTP设置。

Read more about how to set this up here: http://www.quackit.com/php/tutorial/php_mail_configuration.cfm 在此处阅读有关如何进行设置的更多信息: http : //www.quackit.com/php/tutorial/php_mail_configuration.cfm

If you want to set up your own SMTP server, I dont have any good tips on top of my head, but there are several free server softwares out there. 如果您想设置自己的SMTP服务器,我头上没什么好提示,但是那里有几种免费的服务器软件。 Although, you would probably be better off using a public one, or even you ISP SMTP server. 虽然,使用公共服务器甚至是ISP SMTP服务器可能会更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM