www.webdeveloper.com
Results 1 to 2 of 2

Thread: [RESOLVED] phpmailer email sent but no attachment

  1. #1
    Join Date
    Dec 2008
    Posts
    135

    resolved [RESOLVED] phpmailer email sent but no attachment

    I am using the below script to allow user to upload images and email it to me. I did received the email but there is no attachment. It also show the from email as root user instead of the user's email address. please help.

    PHP Code:
    <?php
        ob_start
    ();
        require(
    "class.phpmailer.php");
        
        
    $salutation        $_POST['salutation'];
            
    $firstname         $_POST['firstname'];
            
    $lastname          $_POST['lastname'];
            
    $email             $_POST['email'];
            
    $photo             $_FILES['photo'];
        
        isset(
    $_POST['submit']);
        
    $active_keys = array();
        foreach(
    $_FILES[$photo]['name'] as $key => $filename)
        {
        if(!empty(
    $filename))
        {
            
    $active_keys[] = $key;
        }    }
        
    foreach(
    $active_keys as $key)
    {    switch(
    exif_imagetype($_FILES[$photo]['tmp_name'][$key])) {
        case 
    IMAGETYPE_JPEG:
        case 
    IMAGETYPE_PNG:
            break;
        default:
            echo 
    "{";
            echo        
    "error: 'This is no photo..'\n";
            echo 
    "}";
            exit(
    0);
    } }
        
    $message "Photo submitted by: $salutation $firstname $lastname.  <br>Comments: $comments.<br>terms:$terms.";
       
        
    $mail = new PHPMailer();
       
        
    $mail->From     = ($email);
        
    $mail->AddAddress('info@domain.com');

        
    $mail->Subject  "Submitted Photos";
        
    $mail->Body     $message;
        
    $mail->WordWrap 50;

        foreach(
    $FILES['photo']['tmp_name'] as $photo) {
        if(!empty(
    $photo)) {
            
    $mail->AddAttachment($photo);
        }}

        
    $mail->Send();
        
        
    header("Location: thankyou.php");
           exit();     
        
    ?>

  2. #2
    Join Date
    May 2004
    Location
    chennai, tamil nadu, India
    Posts
    448
    foreach($FILES['photo']['tmp_name'] as $photo) {

    should be

    foreach($_FILES['photo']['tmp_name'] as $photo) {
    Chris, Senior Developer,
    Php laravel developers,
    www.chrisranjana.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles