联系页面无法正常工作
几分钟前刚刚加入。
我想看看是否有人能够告诉我为什么我的联系页面不向我发送电子邮件。
我的联系页面位于此处,
我没有收到任何错误。如果您输入您的信息,它似乎会发送该信息。它甚至会向您显示您的电子邮件已发送的消息。但我没有收到任何电子邮件。
在我的 Doctype 上方
formprocess.php 的编码如下 [我已取出电子邮件以避免垃圾邮件]:
<?php
include('includes/corefuncs.php');
if (function_exists('nukeMagicQuotes')) {
nukeMagicQuotes();
}
// process the email
if (array_key_exists('send', $_POST)) {
$to = '[email protected]'; // use your own email address
$subject = 'Email from your contact form';
// list expected fields
$expected = array('name', 'email', 'comments');
// set required fields
$required = array('name', 'email', 'comments');
// create empty array for any missing fields
$missing = array();
// assume that there is nothing suspect
$suspect = false;
// create a pattern to locate suspect phrases
$pattern = '/Content-Type:|Bcc:|Cc:/i';
// function to check for suspect phrases
function isSuspect($val, $pattern, &$suspect) {
// if the variable is an array, loop through each element
// and pass it recursively back to the same function
if (is_array($val)) {
foreach ($val as $item) {
isSuspect($item, $pattern, $suspect);
}
}
else {
// if one of the suspect phrases is found, set Boolean to true
if (preg_match($pattern, $val)) {
$suspect = true;
}
}
}
// check the $_POST array and any sub-arrays for suspect content
isSuspect($_POST, $pattern, $suspect);
if ($suspect) {
$mailSent = false;
unset($missing);
}
else {
// process the $_POST variables
foreach ($_POST as $key => $value) {
// assign to temporary variable and strip whitespace if not an array
$temp = is_array($value) ? $value : trim($value);
// if empty and required, add to $missing array
if (empty($temp) && in_array($key, $required)) {
array_push($missing, $key);
}
// otherwise, assign to a variable of the same name as $key
elseif (in_array($key, $expected)) {
${$key} = $temp;
}
}
}
// validate the email address
if (!empty($email)) {
// regex to ensure no illegal characters in email address
$checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
// reject the email address if it doesn't match
if (!preg_match($checkEmail, $email)) {
array_push($missing, 'email');
}
}
// go ahead only if not suspect and all required fields OK
if (!$suspect && empty($missing)) {
// build the message
$message = "Name: $name\n\n";
$message .= "Email: $email\n\n";
$message .= "Comments: $comments";
// limit line length to 70 characters
$message = wordwrap($message, 70);
// create additional headers
/*$additionalHeaders = 'From: Frank Juval Studio Site';
if (!empty($email)) {
$additionalHeaders .= "\r\nReply-To: $email";
}*/
// send it
$mailSent = mail($to, $subject, $message, $additionalHeaders);
if ($mailSent) {
// $missing is no longer needed if the email is sent, so unset it
unset($missing);
}
}
}
?>
我不是 PHP 程序员。我从一个免费提供该代码和教程的网站上获取了该代码。我的专长是 HTML/CSS。最终我会进入PHP。
感谢您提前的帮助。
坦率
Just joined a couple of minutes ago.
I wanted to see if anyone might be able to tell me why my contact page isn't sending me emails.
My contact page is here
I don't get any errors. If you enter your info, it seems like it sends it. It even gives you the message that your email has been sent. Yet I don't get any emails.
Above the Doctype I have
The formprocess.php is coded like this [I've taken out my email in order to avoid spam]:
<?php
include('includes/corefuncs.php');
if (function_exists('nukeMagicQuotes')) {
nukeMagicQuotes();
}
// process the email
if (array_key_exists('send', $_POST)) {
$to = '[email protected]'; // use your own email address
$subject = 'Email from your contact form';
// list expected fields
$expected = array('name', 'email', 'comments');
// set required fields
$required = array('name', 'email', 'comments');
// create empty array for any missing fields
$missing = array();
// assume that there is nothing suspect
$suspect = false;
// create a pattern to locate suspect phrases
$pattern = '/Content-Type:|Bcc:|Cc:/i';
// function to check for suspect phrases
function isSuspect($val, $pattern, &$suspect) {
// if the variable is an array, loop through each element
// and pass it recursively back to the same function
if (is_array($val)) {
foreach ($val as $item) {
isSuspect($item, $pattern, $suspect);
}
}
else {
// if one of the suspect phrases is found, set Boolean to true
if (preg_match($pattern, $val)) {
$suspect = true;
}
}
}
// check the $_POST array and any sub-arrays for suspect content
isSuspect($_POST, $pattern, $suspect);
if ($suspect) {
$mailSent = false;
unset($missing);
}
else {
// process the $_POST variables
foreach ($_POST as $key => $value) {
// assign to temporary variable and strip whitespace if not an array
$temp = is_array($value) ? $value : trim($value);
// if empty and required, add to $missing array
if (empty($temp) && in_array($key, $required)) {
array_push($missing, $key);
}
// otherwise, assign to a variable of the same name as $key
elseif (in_array($key, $expected)) {
${$key} = $temp;
}
}
}
// validate the email address
if (!empty($email)) {
// regex to ensure no illegal characters in email address
$checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
// reject the email address if it doesn't match
if (!preg_match($checkEmail, $email)) {
array_push($missing, 'email');
}
}
// go ahead only if not suspect and all required fields OK
if (!$suspect && empty($missing)) {
// build the message
$message = "Name: $name\n\n";
$message .= "Email: $email\n\n";
$message .= "Comments: $comments";
// limit line length to 70 characters
$message = wordwrap($message, 70);
// create additional headers
/*$additionalHeaders = 'From: Frank Juval Studio Site';
if (!empty($email)) {
$additionalHeaders .= "\r\nReply-To: $email";
}*/
// send it
$mailSent = mail($to, $subject, $message, $additionalHeaders);
if ($mailSent) {
// $missing is no longer needed if the email is sent, so unset it
unset($missing);
}
}
}
?>
I'm no PHP programmer. I grabbed this code from a site that provides it for free with a tutorial. My expertise is HTML/CSS. Eventually I'll get into PHP.
Thanks for the help in advance.
Frank
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用更简单的方法:
如果已发送,则脚本可能是问题所在。如果不是,那么您的主机可能不支持发送电子邮件。
Try with something much simpler:
If it is sent, then the script might be the problem. If it is not, then your host might not support sending email.