gpt4 book ai didi

php - 简单的php邮件不发送电子邮件

转载 作者:行者123 更新时间:2023-12-04 06:21:47 25 4
gpt4 key购买 nike

谁能看看这有什么问题吗?我没有收到任何错误,但从未收到电子邮件。

    <?php
if(isset($_POST['email'])) {

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "munged@example.com";
$email_subject = "Email sent through crankapps website";

function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}

// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['message'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}

$name = $_POST['name']; // required
$email = $_POST['email']; // required
$message = $_POST['message']; // required

$error_message = "";
$email_message = "Form details below.\n\n";

$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
$email_message .= "Message: ".clean_string($message)."\n";


// create email headers
$headers = "From: ". $name . " <" . $email . ">\n.";
mail($email_to, $email_subject, $email_message, $headers);
?>

最佳答案

首先,只用一行测试:

<?php
mail('munged@example.com', 'test email', 'this is a test');
?>

这可能是行不通的。

找出您的 smtp 设置并查看 php.ini 中的 smtp 设置是否与它们匹配。

看看 phpmailer,它可以让您使用更多的 smtp 设置,如 ssl 等。

关于php - 简单的php邮件不发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6461714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com