misslilbit02 Posted July 13, 2007 Share Posted July 13, 2007 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"; } ?> Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted July 13, 2007 Share Posted July 13, 2007 is your spam filter catching it? Quote Link to comment Share on other sites More sharing options...
Glyde Posted July 13, 2007 Share Posted July 13, 2007 Linux or Windows? SMTP or Sendmail? Quote Link to comment Share on other sites More sharing options...
misslilbit02 Posted July 13, 2007 Author Share Posted July 13, 2007 No the spam filter isn't catching it and it's a windows server. We use SMTP. Quote Link to comment Share on other sites More sharing options...
Glyde Posted July 13, 2007 Share Posted July 13, 2007 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. Quote Link to comment Share on other sites More sharing options...
misslilbit02 Posted July 13, 2007 Author Share Posted July 13, 2007 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"; Quote Link to comment Share on other sites More sharing options...
Glyde Posted July 13, 2007 Share Posted July 13, 2007 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"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.