2017-02-23 78 views
-1

你好我有三四頁 1.config文件 2.form文件 3.form執行文件 4.send PHP的郵件文件 每一件事情是好的,如果我要去使用phpmmailer,如果我添加phpmailer代碼,然後發送郵件代碼後,其餘代碼不起作用。後的PHPMailer發送代碼變化的代碼不工作

我展示500內部服務器錯誤

執行文件代碼:

sendCustomerMail($myassigneduser->email, "Customer Status Change", "templatefile.php", $message, $headers, $other);  
$db = new db(); 

發送郵件文件:

<?php 
//in this code i'm getting error 
require 'phpmailer/PHPMailerAutoload.php'; 
$templatepath = $_SERVER['DOCUMENT_ROOT'].'/customer/Templates/'; 
$body = file_get_contents($templatepath.$template_name); 
$other['--TEMPLATE_URL--'] = $templatepath; 
foreach($other as $k => $v) { 
    $body = str_replace($k,$v,$body); 
} 
$body = wordwrap(trim($body), 70, "\r\n"); 
$body = convert_smart_quotes($body); 
$mail = new PHPMailer;     
$mail->SMTPDebug = 0; 
$mail->Debugoutput = 'html'; 
$mail->Host = $email_hostname;     
$mail->Username = $email_username; 
$mail->Password = $email_password; 
$mail->setFrom($from_email, $company_name); 
$mail->addReplyTo($from_email, $company_name); 
$mail->addAddress($to, ''); 
$mail->Subject = $subject; 
$mail->msgHTML($body); 
if (!$mail->send()) { 
    return 1; 
} else { 
    return 0; 
} 



//if i'm use simple php mail whole code is working fine 
$headers = 'From:'.$from_email.'' . "\r\n" .'Reply-To:'.$from_email.'' . "\r\n" .'X-Mailer: PHP/' . phpversion(); 
$headers .= "MIME-Version: 1.0\r\n"; 
$headers .= "Content-Type: text/html; charset=UTF-8\r\n"; 
$templatepath = $_SERVER['DOCUMENT_ROOT'].'/customer/Templates/'; 
$body = file_get_contents($templatepath.$template_name); 
$other['--TEMPLATE_URL--'] = $templatepath; 
foreach($other as $k => $v) { 
    $body = str_replace($k,$v,$body); 
} 
$body = wordwrap(trim($body), 70, "\r\n"); 
$body = convert_smart_quotes($body); 
if (mail($to,$subject,$body,$headers)) { 
    return 1; 
}else{ 
    return 0; 
} 
?> 

注:這所有的代碼通過ajax工作

+0

做一些基本的PHP調試,看了一些文檔,看在你的Web服務器日誌,它會顯示你的錯誤。 – Synchro

+0

好的,謝謝,我會做的。 –

回答

1

更改此代碼:

<?php 
    require_once 'phpmailer/PHPMailerAutoload.php'; 
    require_once 'db.php'; 
?> 
+0

偉大的工作:)謝謝@Dhruvin –