php mailer in function会产生错误

时间:2017-06-07 20:17:47

标签: php server phpmailer internal-server-error

我创建了一个使用PHPMailer处理电子邮件发送的函数

这是功能:

function sendEmail($from, $replyTo, $to, $subject, $message) {
$mail = new PHPMailer;

//$mail->SMTPDebug = 3;                               // Enable verbose debug output

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'mail.pickbyclick.ro';  // Specify main and backup SMTP servers
$mail->SMTPAuth = false;
$mail->Username = 'admin@pickbyclick.ro';
$mail->Port = 25; 

$mail->setFrom($from, 'Pick by Click Team');
$mail->addReplyTo($replyTo);
$mail->addAdress($to);
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = emailShowNice($message);
$mail->AltBody = $message;
if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}

}

此次通话后

sendEmail($from, "no-reply@pickbyclick.ro", $to, $subject, $message);

显示500错误服务器。有人可以帮帮我吗?

编辑:这是emailShowNice函数

function emailShowNice($message) {

$order   = array('\r', '\n', '\r\n', "\r", "\n", "\r\n");
$replace = ' <br /> ';

$mes = str_replace($order, $replace, $message);

return $mes;
}

1 个答案:

答案 0 :(得分:1)

将错误的行替换为

$mail->addAdress($to);

$mail->addAddress($to);