此代码用于我的联系页面,它会发出一封电子邮件,我可以使用 gmail 阅读。
<?php
$message = "Sender:" . "\r\n" . $_POST["email"] . "\r\n" . "\r\n" . "Company Name:" . "\r\n" . $_POST["company"] . "\r\n" . "\r\n" .'Message:' . "\r\n" . $_POST["message"];
$to = "EMAIL ADDRESS TAKEN OUT FOR SECURITY PURPOSES, IT'S LEGIT";
$subject = $_POST["title"];
$body = $message;
$headers = 'From:' . $_POST["email"] . "\r\n" .
'Reply-To:' . $_POST["email"] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (mail($to, $subject, $body, $headers)) {
echo("<p class='form'>You're message was sent successfully! We'll get back to you shortly. In the mean-time... ");
} else {
echo("<p class='form'>Oops! There was an error sending your message.");
}
?>
但是,当我将此代码放入另一个页面时...
$message = "Hey, testing this. Go to this link <a href='WEB ADDRESS HIDDEN=" .$display ."'>Activate</a>" ;
$subject = "Activate your Account";
if (mail($email, $subject, $message))
{
echo "A verification link was sent to <strong>".$email."</strong>";
}
它不发送电子邮件!$email 是我之前用来插入数据库的变量。用户输入了它。之后,我向他们发送了一封电子邮件,但它没有发送。Mail() 返回 true,因为它也使用正确的电子邮件地址打印文本。
这里有什么问题?有什么建议么?
我是 php 新手,所以.. 试着像第一次学习一样说话。
谢谢!
编辑:
变量不相关。他们不说话。它们具有相同的名称,但存在于彼此无关的不同页面上。