Jump to content

mail with attachments


lional

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/123305-mail-with-attachments/
Share on other sites

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

 

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!";
        }

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.