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
لبنان يا بلد صغير بالقلب كبير
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 );
?>
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
لبنان يا بلد صغير بالقلب كبير
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).
i fixed the name attribute but still im getting the same, i get the email message but no attachements,
thank you
Noor
لبنان يا بلد صغير بالقلب كبير
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
Last edited by bokeh; 03-30-2007 at 08:22 AM .
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
لبنان يا بلد صغير بالقلب كبير
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 .
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
لبنان يا بلد صغير بالقلب كبير
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
Forum Rules
Bookmarks