简体   繁体   English

警告:mail():无法连接到“localhost”端口25上的邮件服务器,验证php.ini中的“SMTP”和“smtp_port”设置或使用ini_set()

[英]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()

I want to send an Email using PHP when a contact form is submitted .. 我想在提交联系表单时使用PHP发送电子邮件。

Here's my index.php: 这是我的index.php:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Simple PHP Contact Form</title>
    <meta name="HandheldFriendly" content="true">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>

<body>
  <div class="wrapper">  
    <div id="contact_form">
    <form name="form1" id="ff" method="post" action="insert.php">
    <h1>Responsive HTML5 Contact Form Demo</h1>
    <p>This is a working demo of HTML5 and PHP Responsive Contact Form. The form is so simple, that you can implement it in a few minutes.</p>    
        <label>
        <span>Name*:</span>
        <input type="text" placeholder="Please enter your name" name="name" id="name" required autofocus>
        </label>

        <label>
        <span>City*:</span>    
        <input type="text" placeholder="Please enter your city" name="city" id="city" required>
        </label>

        <label>
        <span>Phone:</span>
        <input type="tel" placeholder="Please enter your phone" name="phone" id="phone">
        </label>

        <label>
        <span>Email*:</span>
        <input type="email" placeholder="youremail@gmail.com" name="email" id="email" required>
          </label>

        <input class="sendButton" type="submit" name="Submit" value="Send">

    </form>
    </div>
   </div>

</body>
</html>

Here's my insert.php: 这是我的insert.php:

<?php

// Get values from form
$name=$_POST['name'];
$city=$_POST['city'];
$phone=$_POST['phone'];
$email=$_POST['email'];

$to = "mymail@gmail.com";
$subject = "Future Tutorials Contact Form Test";
$message = " Name: " . $name . "\r\n City: " . $city . "\r\n Phone: " . $phone . "\r\n Email: " . $email;


$from = "FutureTutorials";
$headers = "From:" . $from . "\r\n";
$headers .= "Content-type: text/plain; charset=UTF-8" . "\r\n"; 

if(mail($to,$subject,$message,$headers))
{
  print "Hello";
  // Created by Future Tutorials
}else{
  echo "Error! Please try again.";
}



?>

When I press the submit button it shows the following Error Message 当我按下提交按钮时,它显示以下错误消息

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()

. But I couldn't find the cause of the error here. 但我在这里找不到错误的原因。

The original email I have omitted here. 我在这里省略了原始电子邮件。 Thanks 谢谢

what error message it writes? 它写的是什么错误信息? I recommend you to use phpmailer. 我建议你使用phpmailer。

暂无
暂无

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

相关问题 mail():无法通过“ localhost”端口25连接到邮件服务器,无法在php.ini中验证“ SMTP”和“ smtp_port”设置,或使用ini_set() - mail(): Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set() mail():无法在“localhost”端口 25 连接到邮件服务器,请验证 php.ini 中的“SMTP”和“smtp_port”设置 - mail(): Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” and “smtp_port” setting in php.ini 无法通过“ localhost”端口587连接到邮件服务器,无法在php.ini中验证您的“ SMTP”和“ smtp_port”设置,或在wamp服务器中使用ini_set() - Failed to connect to mailserver at “localhost” port 587, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set() in wamp server 警告:mail()[function.mail]:无法连接到“localhost”端口25的邮件服务器,验证你的“SMTP”和“smtp_port”,XAMPP for WIndows XP - Warning: mail() [function.mail]: Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” and “smtp_port”, XAMPP for WIndows XP PHP:mail()函数,运行时为ini_set(),SMTP和SMTP_PORT不在Linux上运行 - PHP: mail() function with runtime ini_set() for SMTP and SMTP_PORT not working on Linux 无法连接到“localhost”端口25上的邮件服务器,验证您的“SMTP” - Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” Php ini_set mail smtp - Php ini_set mail smtp 我更改了SMTP和SMTP端口,但它仍然说无法连接到“localhost”端口25的邮件服务器 - I changed the SMTP and SMTP Port but it still says Failed to connect to mailserver at “localhost” port 25 mail()函数ini_set()smtp服务器本地主机不起作用 - mail() function ini_set() smtp server localhost not work 警告:mail()[function.mail]:无法通过“ localhost”端口25连接到邮件服务器 - Warning: mail() [function.mail]: Failed to connect to mailserver at “localhost” port 25
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM