消息无法发送.Mailer错误:无法实例化邮件功能

时间:2014-08-26 18:03:16

标签: php function email message

我已经在每个相关/类似的帖子中尝试过解决方案,但没有运气。我的客户变得焦躁不安。这段代码好几个月都运行良好。香港专业教育学院尝试使用您看到注释掉的STMP,但后来我收到连接错误。它是安装了最新PHPMailer的Linux服务器。

    require 'PHPMailer/PHPMailerAutoload.php';

 $mail = new PHPMailer;
 $mail->CharSet = 'UTF-8';
 $mail->IsMAIL();
 //$mail->isSMTP();                                      // Set mailer to use SMTP
 date_default_timezone_set('Etc/UTC');
 //$mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers  
 //$mail->Port = 587; // Enable encryption, 'ssl' also accepted
 //$mail->SMTPSecure = 'tls'; 
 //$mail->SMTPAuth = true;                               // Enable SMTP authentication
 //$mail->Username = "test@gmail.com";                 // SMTP username
 //$mail->Password = "password";                           // SMTP password

 $address = "test@gmail.com";
 $mail->From = "test@gmail.com";
 //$mail->FromName = 'FleetwayCapital.com'; 
 //$mail->addAddress('credit.fcc@fleetwaycapital.com', 'Fleetway Capital');     // Add a        recipient
 $mail->AddAddress($address);
 //$mail->addAddress('test@gmail.com');               // Name is optional
 $mail->addReplyTo("test@gmail.com");
 //$mail->addCC('cc@example.com'); 
 //$mail->addBCC('test@gmail.com');

 $mail->WordWrap = 50;                                 // Set word wrap to 50 characters
 //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
 //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
 $mail->isHTML(true);                               // Set email format to HTML
 $mail->SMTPDebug = 2;
 $mail->Subject = 'Credit Application Submission';
 $mail->Body    = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  
 <title>Untitled Document</title>
 <style type="text/css">
  body,td,th {
   color: #000; 
  }

  .text {
   font-family:Arial, Helvetica, sans-serif;
   margin:auto;
  width:500px;
   font-size:15px;

   }
   </style>
   </head>

   <body>
   <div class="em"><div class="text"><br /><br />
    A client has submitted a credit application.<br /><br /> 



    Have a lovely day!<br />

    End of message
    </div>
    </div>
    </body> 
    </html>'
    ;

    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    if(!$mail->send()) {
     echo 'Message could not be sent.';
     echo 'Mailer Error: ' . $mail->ErrorInfo;
     } else {
     echo 'Message has been sent'; 
     } 

我不确定php.ini文件中应该包含什么,或者如何判断sendmail是否已安装。就像我说的,它工作好几个月了,我在PHPmailer安装的其他服务器上从未遇到过这个问题任何帮助都会很棒。

0 个答案:

没有答案