【发布时间】:2012-02-04 19:30:28
【问题描述】:
据建议,我曾尝试使用 PHP Mailer 发送带有表单的电子邮件附件,但是我不断收到错误消息“Mailer 错误:无法实例化邮件功能。
我已经重新检查了电子邮件地址,但没有发现任何错误
这里是 PHP 的代码以及表单的代码。非常感谢任何输入。谢谢,JB
<html>
<head>
<title>PHPMailer - Mail() basic test</title>
</head>
<body>
<?php
require_once('class.phpmailer.php');
$mail = new PHPMailer(); // defaults to using php "mail()"
$body = file_get_contents('talent3.html');
$body = eregi_replace("[\]",'',$body);
$mail->AddReplyTo("jbgraphics@rogers.com","First Last");
$mail->SetFrom('jbgraphics@rogers.com', 'First Last');
$mail->AddReplyTo("jbgraphics@rogers.com","First Last");
$address = "jbgraphics@rogers.com";
$mail->AddAddress($address, "John Beadle");
$mail->Subject = "PHPMailer Test Subject via mail(), basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAttachment("images/phpmailer.pdf"); // attachment
$mail->AddAttachment("images/phpmailer_mini.jpeg"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
</body>
</html>
及表格代码:
<form action="test_mail_basic.php" method="post"
enctype="multipart/form-data">
<label for="file" class="bodyCopy"><span class="bodyCopy">Attach resume:</span></label><br />
<input type="file" name="attach1" id="file" /><br />
<br />
<label for="file" class="bodyCopy"><span class="bodyCopy">Attach photo:</span></label><br />
<input type="file" name="attach2" id="file" /><br />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
【问题讨论】:
标签: php