lional Posted September 8, 2008 Share Posted September 8, 2008 Hi I am trying to create a script where I can send a mail with one or more attachments. The files are all stored in an uploads directory, and each one has an entry in a mysql table. I would like to run the script, have it search for all uploaded files based on a specific reference number and then send it as a mail to a predefined email address attching all the files in one email I wouyld like to pull the filenames from the mysql table Any ideas, or scripts that are already available will be graetly appreciated Thanks Lional Quote Link to comment Share on other sites More sharing options...
lional Posted September 8, 2008 Author Share Posted September 8, 2008 I am working on solving my own problem. I have a table listing the files uploaded by a reference number. Say my table consists of file1.jpg, file2.jpg, file3.jpg, file4.jpg, and file5.jpg all entries are entered into an attachments table with the same reference number. who will I be able to create the line below $files = array("file1.jpg","file2.jpg","file3.jpg","file4.jpg","file5.jpg"); Thanks Quote Link to comment Share on other sites More sharing options...
toivo Posted September 8, 2008 Share Posted September 8, 2008 There are mail classes available like PHPMailer from http://phpmailer.codeworxtech.com/ or PEAR::Mail which support attachments. Quote Link to comment Share on other sites More sharing options...
lional Posted September 9, 2008 Author Share Posted September 9, 2008 I have it working, I just need to create the array I mentioned from my table Quote Link to comment Share on other sites More sharing options...
lional Posted September 9, 2008 Author Share Posted September 9, 2008 What content-type would I use that would enable me to send attachments and html text in the same mail $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 9, 2008 Share Posted September 9, 2008 EXAMPLE this way you can move the pictures and title them how u want............ <?php //database connection....... $sql="SELECT * FROM DATABASE_FIELD"; $result=mysql_query($sql); while($res=mysql_fetch_assoc($result)){ $pic1=$res['picture1']; $pic2=$res['picture2']; $pic3=$res['picture3']; $pic4=$res['picture4']; $pic5=$res['picture5']; $mess=" database message is: ".$res['message']." <br> Your pic 1 was: $picture1 <br> Your pic 2 was: $picture2 <br> Your pic 3 was: $picture3 <br> Your pic 4 was: $picture4 <br> Your pic 5 was: $picture5 "; $to = $res['mail']; $subject = 'Enquire off $enquire-type'; $message = $mess; $headers = 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; if(mail($to, $subject, $message, $headers)){ echo "Mail sent!"; }else{ echo "Mail not sent!"; } } ?> 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.