首页 > 解决方案 > 无法连接到邮件服务器 PHP

问题描述

我刚开始学习 PHP,正在尝试使用 mail() 函数。我使用 XAMPP 服务器来运行脚本并有一个表单,其中值应该通过电子邮件发送给我。但是,一旦提交表单并重定向到我的 php 文件,我就会收到错误消息

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:\xampp\htdocs\Php files\woah\woah.php on line 13

这是我的 HTML 和 PHP 脚本

哇.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form method="POST" action="woah.php">
        <label for="Typed1">Type 1</label>
        <input type="text" name="Typed1"><br>
        <label for="Typed2">Type 2</label>
        <input type="text" name="Typed2"><br>
        <label for="submit">Submit form</label>
        <input type="submit" name="submit">
    </form>
</body>
</html>

来自 woah.php

<html>
    <head>
        <title>Yooo php</title>
    </head>
    <body>
<?php
    $Type1=$_POST['Typed1'];
    $Type2=$_POST['Typed2'];

    $to='experimenting.Logan@gmail.com';
    $Message='Yo you typed '.$Type1. ' and also '. $Type2;

    mail($to,' ',$Message,'From: Yes');
?>
    </body>
</html>

标签: phpxampp

解决方案


推荐阅读