Jump to content

PHP Mailer Help


misslilbit02

Recommended Posts

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?

 

 

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



?>

Link to comment
Share on other sites

You have to tell PHPMailer that you use SMTP, then.

Try adding

$mail->IsSMTP();
$mail->Host = "smtphost";
$mail->Username = "smtpusername";
$mail->Password = "smtppassword";

Somewhere before you execute $mail->Send() and see if that fixes your problem.

Link to comment
Share on other sites

I did that before and got all these errors:

 

PHP Warning: PHPMailer::include_once(class.smtp.php) [function.PHPMailer-include-once]: failed to open stream: No such file or directory in C:\php\includes\class.phpmailer.php on line 460 PHP Warning: PHPMailer::include_once() [function.include]: Failed opening 'class.smtp.php' for inclusion (include_path='.;\php\includes') in C:\php\includes\class.phpmailer.php on line 460 PHP Fatal error: Class 'SMTP' not found in C:\php\includes\class.phpmailer.php on line 527 

 

I don't even have a line 527.

 

but this is what was there:

$mail->IsSMTP();

$mail->Host = "tim";

Link to comment
Share on other sites

class.phpmailer.php is generating the error, not your script.  The error is generated because it can't find class.smtp.php, which should come packaged with PHPMailer.  Go to http://phpmailer.sourceforge.net and redownload the package, or locate class.smtp.php and move it in the same directory with PHPMailer.  Additionally, $mail->Host shouldn't be a username (because that's how it appears right now).  If it is a valid name (by valid I mean that it backtraces to a valid IP address), then fine, but it seems like you're using a username where a host should be, I.E:

$mail->Host = "localhost";

or

$mail->Host = "smtp.myserver.com";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.