嗨,我有三页四页 1.config文件 2.form文件 3.form执行文件 4.发送php邮件文件 如果我要使用phpmmailer,如果我在发送邮件代码之后添加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 :(得分:1)
更改此代码:
<?php
require_once 'phpmailer/PHPMailerAutoload.php';
require_once 'db.php';
?>