Page 1 of 1

PHP Mailer Help

Posted: Fri Jul 13, 2007 3:36 pm
by misslilbit02
Hey guys,

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";
}

Posted: Fri Jul 13, 2007 11:32 pm
by feyd
I would suspect your settings regarding mail are incorrect in PHP's settings. I would suggest switching to Swiftmailer and use it's SMTP connector.

Posted: Sat Jul 14, 2007 12:44 pm
by ankhmor
Are you the owner of the server or are buying hosting?