我试图用梨发送电子邮件。这里是我的代码无法使用PHP梨发送电子邮件
<?php
require_once "/usr/share/pear/Mail.php";
require_once "/usr/share/pear/Mail/mime.php";
$to = "Info <[email protected]>";
$subject = "Contact Form - mydomain.com\r\n\r\n";
$host = "smtp.zoho.com";
$username = "[email protected]";
$password = "[email protected]";
$port = "465";
//Sender Details
$sender_name = $_POST['name'];
$from = $_POST['name']." <".$_POST['email'].">";
$sender_phone = $_POST['phone'];
//Create Message
$body = $_POST['message'];
//$body = wordwrap($body, 70, "\r\n");
$body = $body . "\r\n" . "Phone: " .$sender_phone;
if($sender_name != "" && $_POST['email'] != "" && $body != "" && $sender_phone != "")
{
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject,
'Reply-To: ' => $from);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
header("Location:contact-us.php?mcode=1");
}
}
else
{
header("Location:contact-us.php?mcode=2");
}
?>
下面这段代码给了我在浏览器中出现以下错误:
当我检查我的PHP error_log
我发现这一点:
[Tue Dec 17 08:46:56 2013] [notice] child pid 7416 exit signal Segmentation fault (11) [Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Notice: Undefined index: name in /var/www/html/contact-us-process.php on line 14 [Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Stack trace: [Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP 1. {main}() /var/www/html/contact-us-process.php:0 [Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Notice: Undefined index: name in /var/www/html/contact-us-process.php on line 15 [Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Stack trace: [Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP 1. {main}() /var/www/html/contact-us-process.php:0 [Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Notice: Undefined index: email in /var/www/html/contact-us-process.php on line 15 [Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Stack trace: [Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP 1. {main}() /var/www/html/contact-us-process.php:0 [Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Notice: Undefined index: phone in /var/www/html/contact-us-process.php on line 16 [Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Stack trace: [Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP 1. {main}() /var/www/html/contact-us-process.php:0 [Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Notice: Undefined index: message in /var/www/html/contact-us-process.php on line 19 [Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP Stack trace: [Tue Dec 17 08:47:44 2013] [error] [client 117.198.137.57] PHP 1. {main}() /var/www/html/contact-us-process.php:0 [Tue Dec 17 08:47:45 2013] [notice] child pid 6887 exit signal Segmentation fault (11) [Tue Dec 17 08:50:26 2013] [notice] child pid 7414 exit signal Segmentation fault (11) [Tue Dec 17 09:35:48 2013] [error] [client 117.198.124.73] File does not exist: /var/www/html/favicon.ico [Tue Dec 17 09:39:46 2013] [notice] child pid 8617 exit signal Segmentation fault (11)
我使用Zoho电子邮件系统使用Rackspace云。
当我做:
[[email protected] /]# find -name Mail.php
./usr/share/pear/Mail.php
这就是为什么我直接包含在PHP文件,
此外,当我这样做,
[[email protected] /]# find -name mime.php
./usr/share/pear/Mail/mime.php
所以我用require_once "/usr/share/pear/Mail/mime.php"
,但是这是有在一个例子中,我不太确定我为什么使用这一行。
这可能是什么原因导致我可以解决这个问题?
我可以对你的表格的HTML代码看看吗? php没有从提交的表单中获得帖子值 – sas
@crack页面获取数据,当我删除'require_once'/usr/share/pear/Mail.php';' 'require_once“/ usr/share/pear/Mail/mime.php“;'它echoz一切正常 –
此外,铬加载器旋转分钟,然后这个铬错误来了,[截图有问题] –