我有一个在IIS8上运行的站点,我让PHPMailer工作得很好。然后突然间我开始收到此错误“消息未发送.Mailer错误:无法实例化邮件功能。”它看起来像另一个不使用PHPMailer的php电子邮件表单也不起作用。不工作我的意思是它似乎工作,但电子邮件永远不会出现在我的收件箱中。我不知道这是IIS还是PHP问题。这是PHPMailer表单。
<?php
require_once('assets/PHPMailer/class.phpmailer.php');
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$job = $_POST['job'];
$file = $_FILES['fileUpload']['name'];
$mail = new PHPMailer();
$mail->From = "jobform@url.com";
$mail->FromName = "Job Form";
$address = "email@url.com";
$mail->AddAddress($address);
$mail->WordWrap = 50;
$mail->Subject = " Job Form";
$mail->Body="
First Name: $first_name
Last Name: $last_name
Phone Number: $phone
Email: $email
Job: $job";
$maxsize = 2 * 1024 * 1024;
$types = array('application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document');
if ((isset($_FILES['fileUpload']) && $_FILES['fileUpload']['error'] == UPLOAD_ERR_OK) && $_FILES['fileUpload']['size'] < $maxsize && in_array( $_FILES['fileUpload']['type'], $types)) {
$mail->AddAttachment($_FILES['fileUpload']['tmp_name'],
$_FILES['fileUpload']['name']);
} else {
echo 'Please upload a PDF or Word Document that is under 2MB';
exit();
}
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email)) {
echo 'Please enter a valid email address';
exit();
}
if($first_name == '') {
echo 'Please enter your first name';
exit();
}
if($last_name == '') {
echo 'Please enter your last name';
exit();
}
if(!$mail->Send())
{
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
}
else
{
echo 'Thank you for your feedback.';
}
?>