我正在使用mail()
对我的用户 ID 稍作修改的基本示例,我收到错误“邮件程序错误:无法实例化邮件功能”
如果我使用邮件功能 -
mail($to, $subject, $message, $headers);
它工作正常,虽然我在发送 html 时遇到问题,这就是我尝试 PHPMailer 的原因。
这是代码:
<?php
require_once('../class.phpmailer.php');
$mail = new PHPMailer(); // defaults to using php "mail()"
$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);
print ($body ); // to verify that I got the html
$mail->AddReplyTo("reply@domain.com","my name");
$mail->SetFrom('from@domain.com', 'my name');
$address = "to@domain.com";
$mail->AddAddress($address, "her name");
$mail->Subject = "PHPMailer Test Subject via mail(), basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML($body);
$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>