Re: Email an attached file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello!!

If your storing the file name, file type, in mysql; and are storing the files on a server.
(Which you should be doing!!!)




You could use this!!

//------------------------------------

	$query = "SELECT * FROM Images WHERE Num = $num";
	$result = mysql_query ($query, $db);	
	$data = mysql_fetch_object($result);


function sendfile($to, $subject, $text, $cc, $from, $file, $type) { $content = fread(fopen($file,"r"),filesize($file)); $content = chunk_split(base64_encode($content)); $uid = strtoupper(md5(uniqid(time()))); $name = basename($file); $text = stripslashes($text); $subject = stripslashes($subject);

	$header = "From: $from\nReply-To: $from\n";
	$header .= "Cc: $cc\n";
	$header .= "MIME-Version: 1.0\n";
	$header .= "Content-Type: multipart/mixed; boundary=$uid\n";

	$header .= "--$uid\n";
	$header .= "Content-Type: text/plain\n";
	$header .= "Content-Transfer-Encoding: 8bnoit\n\n";
	$header .= "$text\n";
	$header .= "\n";
	$header .= "\n";


$header .= "--$uid\n"; $header .= "Content-Type: $type; name=\"$name\"\n";

	$header .= "Content-Transfer-Encoding: base64\n";
	$header .= "Content-Disposition: attachment; filename=\"$name\"\n\n";
	$header .= "$content\n";

$header .= "--$uid--";

mail($to, $subject, "", $header);

}


$file2 = ("./images/$data->name"); $type = ("$data->filetype");

	$mess .= ("\n");
	$mess .= ("\n");
	$mess .= ("\n");
	$mess .= ("\n");
	$mess .= ("Here is that Pic you wanted...");

sendfile($To, $sub, $mess, $cc, $From, $file2, $type);



//-----------------


Of course all of the $To,$sub,etc...etc...etc...are from posting the data from a form.




I think you can figure out the rest....



Good luck!!




Dan Brunner




On Wednesday, May 28, 2003, at 01:12 PM, jeffrey_n_Dyke@Keane.com wrote:


www.phpclasses.org is your best bet. there are plenty. personally i use
this one..http://phpclasses.com/browse.html/package/32.html


check out his site for examples.

hth
jd





"Marie Osypian"
<mosypian@savingforco To: <php-db@lists.php.net>
llege.com> cc:
Subject: Email an attached file
05/28/2003 02:08 PM







I am using something like this example code below to send e-mail and
wondered if anyone could tell me how I could include a file also in this
email if possible.


Thanks in advance.
Marie


EXAMPLE:


$myname = "Me Myself";
$myemail = "myself@email.com";

$contactname = "Mister Contact";
$contactemail = "contact@email.com";

$message = "hello from happy me";
$subject = "Included your file";

$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$myname." <".$myemail.">\r\n";
$headers .= "To: ".$contactname." <".$contactemail.">\r\n";
$headers .= "Reply-To: ".$myname." <$myreplyemail>\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-MSMail-Priority: High\r\n";
$headers .= "X-Mailer: Just My Server";
mail($contactemail, $subject, $message, $headers);



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux