phpmailer: Could not instantiate mail function

来源:互联网 发布:普莱斯眼镜怎么样 知乎 编辑:程序博客网 时间:2024/06/06 11:02

phpmailer: Could not instantiate mail function

 
浏览:4237 发布日期:2015/05/20 分类:求助交流关键字: 邮件 phpmailer 
自己Mac上面测试完全OK,但是放到Linux的服务器上就报了Could not instantiate mail function.

配置项:
  1. // 配置邮件发送服务器
  2.  'THINK_EMAIL' => array(
  3.     'SMTP_HOST'   => 'smtp.163.com', //SMTP服务器
  4.     'SMTP_PORT'   => '25', //SMTP服务器端口
  5.     'SMTP_USER'   => '***@163.com', //SMTP服务器用户名
  6.     'SMTP_PASS'   => '****', //SMTP服务器密码
  7.     'FROM_EMAIL'  => '***@163.com', //发件人EMAIL
  8.     'FROM_NAME'   => 'XXX', //发件人名称
  9.     'REPLY_EMAIL' => '', //回复EMAIL(留空则为发件人EMAIL)
  10.     'REPLY_NAME'  => '', //回复名称(留空则为发件人名称)
  11.  ),
复制代码
实现函数:
  1. function think_send_mail($to, $name, $subject = '', $body = '', $attachment = null){
  2.     $config = C('THINK_EMAIL');
  3.     vendor('PHPMailer.class#phpmailer'); //从PHPMailer目录导class.phpmailer.php类文件
  4.     $mail             = new PHPMailer(); //PHPMailer对象
  5.     $mail->CharSet    = 'UTF-8'; //设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码
  6.     $mail->IsSMTP();  // 设定使用SMTP服务
  7.     $mail->SMTPDebug  = 0;                     // 关闭SMTP调试功能
  8.                                                // 1 = errors and messages
  9.                                                // 2 = messages only
  10.     $mail->SMTPAuth   = true;                  // 启用 SMTP 验证功能
  11.     $mail->SMTPSecure = 'ssl';                 // 使用安全协议
  12.     $mail->Host       = $config['SMTP_HOST'];  // SMTP 服务器
  13.     $mail->Port       = $config['SMTP_PORT'];  // SMTP服务器的端口号
  14.     $mail->Username   = $config['SMTP_USER'];  // SMTP服务器用户名
  15.     $mail->Password   = $config['SMTP_PASS'];  // SMTP服务器密码
  16.     $mail->SetFrom($config['FROM_EMAIL'], $config['FROM_NAME']);
  17.     $replyEmail       = $config['REPLY_EMAIL']?$config['REPLY_EMAIL']:$config['FROM_EMAIL'];
  18.     $replyName        = $config['REPLY_NAME']?$config['REPLY_NAME']:$config['FROM_NAME'];
  19.     $mail->AddReplyTo($replyEmail, $replyName);
  20.     $mail->Subject    = $subject;
  21.     $mail->MsgHTML($body);
  22.     $mail->AddAddress($to, $name);
  23.     if(is_array($attachment)){ // 添加附件
  24.         foreach ($attachment as $file){
  25.             is_file($file) && $mail->AddAttachment($file);
  26.         }
  27.     }
  28.     return $mail->Send() ? true : $mail->ErrorInfo;
  29. }
复制代码
class.phpmailer.php改动的地方:
  1. public function IsSMTP() {
  2.     $this->Mailer = 'SMTP';
  3.     //$this->Mailer = 'smtp';
  4.   }
复制代码
class.smtp.php改动的地方:
Connect函数
  1.  $this->smtp_conn = @pfsockopen($host,    // the host of the server
复制代码
求各位大神解答
0 0
原创粉丝点击