I've been trying to send an email with an attachment from a form all day. It's just isn't working. So I resorted to PHPmailer. The code executes but no mail is coming. It does return the message "Message has been sent" Can someone help me please?
Code: Select all
<?php
require("C:\php\includes\class.phpmailer.php");
require("C:\php\includes\phpmailer.lang-en.php");
$mail=new PHPMailer();
@extract($_POST);
$langauge2 = implode(', ',$langauge);
$areas2 = implode(', ',$areas);
//$mail->IsSMTP();
//$mail->Host = "localhost";
$mail->Subject="Writing Submittal";
$mail->WordWrap=50;
$mail->From = $email;
$mail->AddAddress("bnikki@keiseruniversity.edu");
$mail->FromName = $name;
$mail->Body = "
Name: $name
Student ID: $student_id
Email address: $email
Home Campus: $campus
Course Title and Number: $course_title_and_no
Is this an online course: $online_course
Professor's Name: $professor
Due Date: $month / $day / $year
What languages do you speak: $langauge2
Have you already taken Composition I (ENC1101): $taken
Writing Title: $title
Assignment Given by Instructor: $assignment
Required length of assignment: $length
Other length if not listed above: $other_length
Two areas where student would like to have feedback: $areas2";
// Obtain file upload vars
$fileatt = $_FILES['upfile']['tmp_name'];
$fileatt_type = $_FILES['upfile']['type'];
$fileatt_name = $_FILES['upfile']['name'];
$headers = "From: $email";
if (is_uploaded_file($fileatt))
{
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file, filesize($fileatt));
$uploadDir=basename($_FILES['upfile']['name']);
// Attach file
//$mail->AddStringAttachment($data, $fileatt);
$mail->AddAttachment($_FILES['upfile']['tmp_name'], $uploadDir);
fclose($file);
}
if(!$mail->Send())
{
echo "Message was not sent";
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}