当用户提交 html 注册表时通过电子邮件向用户发送确认

时间:2021-01-20 21:24:18

标签: php

当您单击提交按钮时,我尝试通过电子邮件发送 html 中的数据,该 html 表单使用 POST 操作。我的php代码是:

<?php
$email = $_POST['email'];
$to      = '$email';                       //email submitted in html form
$subject = 'Welcome ';
$message = 'hello';
$headers = 'From: myaddress@email.com' . "\r\n".
'Reply-To: From: myaddress@email.com' . "\r\n".
'X-Mailer: PHP/' . phpversion();
$result = mail($to, $subject, $message, $headers);
if(!$result) {   
    echo "Error";   
} else {
    echo "Success";
}
?>

我收到一条成功消息,但没有收到电子邮件,任何想法将不胜感激。非常感谢

0 个答案:

没有答案