【发布时间】:2013-11-28 20:51:44
【问题描述】:
我在使 PHP 脚本工作时遇到了一些麻烦。我正在制作一个非常基本的表格,只是收集姓名和电子邮件
<form action"email.php" method="POST" id="signup-form">
<p><input type="text" id="name" name="name" placeholder="name" /></p>
<p><input type="email" id="email" name="email" placeholder="email address" /></p>
<p class="form-note"><em>* we will only email you when our store is up</em></p>
<p><input type="submit" value="Get Notified" /></p>
</form>
我的 PHP 脚本是
<?php
$error = false;
$sent = false;
if(isset($_POST['submit'])) {
if(empty($_POST['name']) || empty($_POST['email'])) {
$error = true;
}
else {
$to = "my.name@gmail.com";
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$subject = "New Subscriber";
$message = "Name: $name \r\n Email: $email";
$headers = "From:" . $name;
$mailsent = mail($to, $subject, $message, $headers);
if($mailsent) {
$sent = true;
}
}
}
?>
我正在使用一家 Linux 托管公司,即网络注册表。我试图打开 PHP 错误,但在我的 cpanel 中看不到。邮件未发送,但我无法看到阻止它的错误。
【问题讨论】:
-
不工作怎么办?你有错误吗?邮件发不出去?怎么了?我们并不住在你的脑海里,也不知道你在想什么。
-
您可以从您的服务器邮件服务器发送电子邮件吗?你在运行xampp吗?还是沼泽?如果是这样,默认情况下未配置电子邮件
-
我更新了在 linux 托管服务器上运行的帖子。 @AmalMurali