Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中使用Pear发送邮件时出现问题_Php_Email_Pear - Fatal编程技术网

在PHP中使用Pear发送邮件时出现问题

在PHP中使用Pear发送邮件时出现问题,php,email,pear,Php,Email,Pear,我已经用php写了一个电子邮件联系表单。我正在使用Pear邮件包发送电子邮件。它在我的开发计算机上运行得很好,但在服务器上却不行。代码如下: ////////////////////////////////////////////////// // EMAIL OPTIONS ////////////////////////////////////////////////// $to = "name@domain.com"; $subject = "Contact F

我已经用php写了一个电子邮件联系表单。我正在使用Pear邮件包发送电子邮件。它在我的开发计算机上运行得很好,但在服务器上却不行。代码如下:

//////////////////////////////////////////////////
// EMAIL OPTIONS
//////////////////////////////////////////////////
$to = "name@domain.com";              
$subject = "Contact Form Submission";           
$smtphost = "localhost";
$port = "25";
$authenticate = false;
$username = "smtp_username";
$password = "smtp_password";

// create and send the email
$from = $_POST['fullname'] . " <" . $_POST['email'] . ">";
$body = str_replace($ph, $rv, $emailTemplate);

$headers = array (
    'MIME-Version' => '1.0',
    'Content-type' => 'text/html; charset=iso-8859-1',
    'From' => $from,
    'To' => $to,
    'Subject' => $subject);

$smtp = Mail::factory('smtp',
  array ('host' => $smtphost,
    'port' => $port,
    'auth' => $authenticate,
    'username' => $username,
    'password' => $password));

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

$error = PEAR::isError($mail);

if ($error){
    echo 'An error occurred.';
}
else {
    require('thanks.php');
    exit;
}

尝试在
$smtphost=“localhost”中进行更改
到您的服务器域url查看并执行以下操作:

if ($error){ echo 'An error occurred.'; echo $error->getMessage(), "\n"; } else { require('thanks.php'); exit; } 如果($error){ 回显“发生错误”; echo$error->getMessage(),“\n”; } 否则{ require('Thank.php'); 出口 }
这并没有回答我关于从$error对象获取更多有用信息的问题。我不担心我的smtp服务器主机出错。 if ($error){ echo 'An error occurred.'; echo $error->getMessage(), "\n"; } else { require('thanks.php'); exit; }