www.webdeveloper.com
Results 1 to 10 of 10

Thread: send email with multiple attachment

  1. #1
    Join Date
    Nov 2005
    Posts
    183

    Question send email with multiple attachment

    hi guys,

    im not finding a code for sending an email with multiple attachment using php,

    any suggestion,

    Regards,

    Noor

  2. #2
    Join Date
    Jun 2006
    Location
    Down at the bottom of the garden
    Posts
    1,239
    You need to format the mail using MIME types.

    PHP Code:
    <?php
    $html    
    "<html><body><H3>This is HTML!</H3></body></html>";
    $data    file_get_contents("myfile.jpg");
    $eol    "\n";

    // Boundary
    $boundary uniqid("FOOBAR");

    // Basic Headers
    $headers  'From: nobody@nowhere'.$eol;
    $headers .= 'MIME-Version: 1.0'.$eol;
    $headers .= 'Content-Type: Multipart/Related; boundary='.$boundary.$eol;
    $headers .= $eol;

    // Text for non-MIME users
    $headers .= "This part of the E-mail should never be seen. If you are reading this, consider upgrading your e-mail client to a MIME-compatible client.".$eol;
    $headers .= $eol;

    // HTML
    $headers .= "--".$boundary.$eol;    
    $headers .= 'Content-Type: text/html; charset=ISO-8859-1'.$eol;
    $headers .= 'Content-Transfer-Encoding: base64'.$eol;
    $headers .= $eol;
    $headers .= chunk_split(base64_encode($html));

    // Image
    $headers .= "--".$boundary.$eol;
    $headers .= 'Content-ID: <123456789>'.$eol;    
    $headers .= 'Content-Type: image/jpeg'.$eol;
    $headers .= 'Content-Transfer-Encoding: base64'.$eol;
    $headers .= $eol;
    $headers .= chunk_split(base64_encode($data));

    // EOF
    $headers .= "--".$boundary."--".$eol;

    $message "";

    mail($to_address$subject$message$headers);
    ?>

  3. #3
    Join Date
    Nov 2005
    Posts
    183

    Red face this code sends mail but no attachements ?? why ?

    hi guys, this code sends only a simple email and it shows in the email that there are atachments but can't find them,,,what am i doing wrong ??

    i have attached the file

    thank you for any help or suggestion

    Regards,

    Noor
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,742
    A couple of problems.
    HTML Code:
    <input type="file" id="file1">
    No name attribute.

    Also, once you sort that out, you are not accessing the FILES array correctly for a multiple upload. For more info look at the sticky (second post).

  5. #5
    Join Date
    Nov 2005
    Posts
    183

    Angry

    i fixed the name attribute but still im getting the same, i get the email message but no attachements,

    thank you

    Noor

  6. #6
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,742
    He's my advice:
    • Try to make your code look as if you care about presentation
    • Validate every input including images
    • Use loops and arrays to make your dropdowns rather than having a huge unnecessary stream of markup

    Here is your script in working order but without the above suggestions:
    Attached Files Attached Files
    Last edited by bokeh; 03-30-2007 at 09:22 AM.

  7. #7
    Join Date
    Nov 2005
    Posts
    183

    Smile

    thank you bokeh for your help,i really appreciate it but the script u sent doesn't work ?? it shows that a message was sent but never reaches my email??

    you can take alook at it here www.starkwi.com/bokeh.php

    regarding the script that i had before, now it's working, i'll attach it so ohters can use it..

    i wonder if there are better and easier way to send email with multiple attachments, like a class or something ??

    thank you again, as usual man you helped me alot before,

    Regards,

    Noor
    Attached Files Attached Files

  8. #8
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,742
    Quote Originally Posted by nooor83
    it shows that a message was sent but never reaches my email?
    It does work because I tested it. If it says message sent that is because your mail exchanger accepted it for relay. You need to look into other things like sending a corresponding from address and maybe using the 5th argument to mail.

  9. #9
    Join Date
    Nov 2005
    Posts
    183
    how do i do that ?? i didn't get what u mean ?

    i was wodering if there is an easier way to do all that, maybe a ready scipt or somethng that can do that whole thing ??

    thanx man

    Noor

  10. #10
    Join Date
    Feb 2011
    Posts
    2
    Hi,

    If you have any issue in sending email with multiple attachments then visit the link below and you will find a comprehensive solution of sending email with multiple attachments in PHP.

    http://www.flairsol.com/send_email_w...hments_php.php

    Thanks,

    Zeeshan

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