Ask a Question related to PHP Development, Design and Development.
-
Leon #1
emailing with an attachment that has fetched from db (longblob)
I am trying to send an email with an attachment.
The problem is the attachment is stored in db where I have created a
longblob field that contains the file so I have no idea how to specify
the file path when I want to send an email.
I have tried "" and "/" that didn't work.
Any help?
My code is
------------------------------------------------------------------------
$fileatt = ""; // Path to the file
$fileatt_type = "text/html"; // File Type
$fileatt_name = "AttachFilename.txt"; // Filename that will be used
for the file as the attachment
$email_from = ""; // Who the email is from
$email_subject = "Testing"; // The Subject of the email
$email_txt = "how are you?"; // Message that the email has in it
$message_text = ""; // Message that the email has in it
$email_to = ""; // Who the email is too
$headers = "From: ".$email_from;
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$email_message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message_text . "\n\n";
$data = chunk_split(base64_encode($data));
$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
$ok = @mail($email_to, $email_subject, $email_message, $headers);
-------------------------------------------------------------------------
Thanks a lot in advance,
Leon Guest
-
#39440 [NEW]: Custom IMAP flags cannot be fetched
From: loikiolki at yahoo dot ca Operating system: Windows XP PHP version: 5.2.0 PHP Bug Type: Feature/Change Request Bug... -
Problem on inserting data in a LONGBLOB field
Hi all, I try to insert data in a LONGBLOB field. Usually it doesn't matter, but depending on which server I execute the query, it fails.... -
Fetched text looses layout...how can I keep it?
Hi! Here's the problem. I have a comments textfield in my insert form. There ppl can type any kind of text, say for example: Hello! Cool site... -
Extension for emailing attachment?
I am looking for a dreamweaver extension (php) that will allow the visitor to attach a file to a form for e-mailing. Ideally, the extension will... -
emailing an attachment
Greetings, I'm looking for some help sending an e-mail attachment via a perl CGI. I'm an experienced programmer, but a Perl moron. Previous... -
Manuel Lemos #2
Re: emailing with an attachment that has fetched from db (longblob)
Hello,
On 10/06/2003 05:28 AM, Leon wrote:You may want to try this class that lets you compose messages with> I am trying to send an email with an attachment.
> The problem is the attachment is stored in db where I have created a
> longblob field that contains the file so I have no idea how to specify
> the file path when I want to send an email.
> I have tried "" and "/" that didn't work.
> Any help?
attachements defined with data taken from strings. It comes with an
example that lets you define the file name to whatever you want:
[url]http://www.phpclasses.org/mimemessage[/url]
--
Regards,
Manuel Lemos
Free ready to use OOP components written in PHP
[url]http://www.phpclasses.org/[/url]
Manuel Lemos Guest



Reply With Quote

