SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: PHP Mailer Help

  1. #1
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Mailer Help

    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 Code:
    <?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($filefilesize($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";
    }



    ?>

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As i had noticed before that directly the uploaded file could not be sent as an attachment with PHPMailer. So i did it first copy the file to a temp folder and sent the mail then deleted the file.

    Remember : After sending the email only delete the file otherwise it will not send the attachment.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •