PHP Mailer Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
misslilbit02
Forum Newbie
Posts: 9
Joined: Mon Sep 18, 2006 3:57 pm

PHP Mailer Help

Post 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";
}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
ankhmor
Forum Newbie
Posts: 12
Joined: Fri Jul 13, 2007 4:45 pm

Post by ankhmor »

Are you the owner of the server or are buying hosting?
Post Reply