php在发送电子邮件时收到错误

时间:2013-06-01 02:11:27

标签: php email

我正在尝试通过php编码发送电子邮件,但收到以下错误

Warning: require_once(Mail.php): failed to open stream: No such file or directory in  /home/madeingu/public_html/sendemail.php on line 5

Fatal error: require_once(): Failed opening required 'Mail.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/madeingu/public_html/sendemail.php on line 5

请检查我的代码,也许你会知道我在哪里做错了

<?php


require_once "Mail.php";


$name="lisa";
$mail_from="xx@xx.com";
$subject="testing";
$message="this is test email";



$header="me"; 
$to = "Shop <xx@xx.com>";

$from = "xx@xx.com";

$host = "mail.xxxxxxx.com";
$username = "xx@xx.com";
$password = "password";

$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
 'auth' => true,
 'username' => $username,
 'password' => $password));

$mail = $smtp->send($to, $headers, $message);


if (PEAR::isError($mail)) {
 echo("<p>" . $mail->getMessage() . "</p>");
  } else {
  //echo("<p>Message successfully sent!</p>");
 echo'<table width="800" border="0" align="center" >
  <td>';
  echo "We've recived your contact information, we will get back soon!";
echo'</td>
</table>';
  }
  ?>

请检查上面的代码对我来说似乎没问题,因为我在网上查了大部分代码。

但也许它与php配置相关,或者php.ini更改..

无论如何,请告诉我。

感谢

2 个答案:

答案 0 :(得分:1)

PHP无法找到您的mail.php文件!

如果您的mail.php文件位于分支上方的目录中,请使用

require_once("../mail.php");

如果它位于文件夹内的同一目录中,请像

一样使用它
require_once("mailer/mail.php");

答案 1 :(得分:0)

您的“Mail.php”文件与“sendmail.php”的路径不存在相同的路径。检查mail.php的路径