【发布时间】:2012-03-15 00:12:47
【问题描述】:
我是 php 的新手。我正在使用预构建的 html 模板。我必须配置下面提到的表单。我更改了两个值:
$emailAdmin = "myemailid@gmail.com",
$urlWebSite = "mydomain.co.cc"
但是当我点击发送电子邮件时。它给出了一条错误消息“发送电子邮件时出现了一些问题。”
<?php
// ------------------------------------------------ -----------------------------------
// CONFIGURATION PARAMETERS OF GENERAL
// ------------------------------------------------ -----------------------------------
$emailAdmin = "myemailid@gmail.com", // email admin where notices are sent
$urlWebSite = "mydomain.co.cc" // Website URL That Is added to the bottom of emails sent from contact form
$headers_mail = "From: Company Name <info@your_domain.com> \ nReply-to: info@your_domain.com";
define ("OGGETTO_MAIL", "Contact from the site.");
$str_contenuto_email = "
You are receiving this email Because someone used the card of contacts on your website.
Here the personal information we have That Contacted:
-------------------------------------------------- -----------
Name and Surname: {name}
E-mail: mail {}
IP Address: {ip}
-------------------------------------------------- -----------
This is the user's request:
-------------------------------------------------- -----------
Message: {body}
-------------------------------------------------- -----------
{url} ";
?>
我忘了提到另外一个我没有配置但默认在包含文件夹中的 php 文件:
<?php
include_once("config.php");
//------------------------------------------------------------------------------------------------
// RECUPERO IL VALORE DI TUTTI I DATI INVIATI DALL'UTENTE
//------------------------------------------------------------------------------------------------
$str_ind_ip = $_SERVER['REMOTE_ADDR'];
foreach ($_POST as $key=>$value) {
$$key = $value;
}
//------------------------------------------------------------------------------------------------
// PROCEDURA DI INVIO MAIL
//-------------------------------------
$str_oggetto = OGGETTO_MAIL;
$str_contenuto_email = str_replace("{name}",$visitor,$str_contenuto_email);
$str_contenuto_email = str_replace("{mail}",$visitormail,$str_contenuto_email);
$str_contenuto_email = str_replace("{ip}", $str_ind_ip,$str_contenuto_email);
$str_contenuto_email = str_replace("{corpo}",$notes,$str_contenuto_email);
$str_contenuto_email = str_replace("{url}",$urlWebSite,$str_contenuto_email);
$headers = $headers_mail;
if (!@mail($emailAdmin,$str_oggetto,$str_contenuto_email,$headers)) {
echo "<div class=\"error\">Have been some problems sending the email.</div>";
} else {
echo "<div class=\"success\">The email has been sent successfully.</div>";
}
【问题讨论】:
-
“发送电子邮件时遇到了一些问题” 不是 PHP 错误,在您发布的代码中找不到它。这个问题目前无法回答,但在stackoverflow.com/questions/tagged/php+email 之前几乎肯定有人问过这个问题
-
你的 mail() 函数在哪里?您定义了很多,但我看不到您将其发送到哪里-请参阅php.net/manual/en/function.mail.php
-
你是对的,它不是 php 错误,而是显示在我的浏览器弹出消息中。
-
现在有弹窗了吗?你遗漏了多少代码?表单本身、对
mail()或库方法的调用、错误消息、弹出响应。还有什么?
标签: php