473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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,
Jul 17 '05 #1
1 2414
Hello,

On 10/06/2003 05:28 AM, Leon wrote:
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?


You may want to try this class that lets you compose messages with
attachements defined with data taken from strings. It comes with an
example that lets you define the file name to whatever you want:

http://www.phpclasses.org/mimemessage

--

Regards,
Manuel Lemos

Free ready to use OOP components written in PHP
http://www.phpclasses.org/

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Bill | last post by:
I am trying to have the capability to email attachments. Specifically I want to be able to email a specific attachment that I name that may be a PDF document, text doc, etc. I already have a...
0
by: Bernhard Schmidt | last post by:
------=_NextPart_000_0099_01C34B87.28543020 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable hi all a question about checking the data of a longblob...
1
by: Bob-O | last post by:
Need your help in sending an email message with an attachment in my VB.Net program. Sending a body message is no problem. I don't know how to use the attachment property in an emai Following is...
1
by: Davide | last post by:
Perche' non riesco ad inserire immagini opiu' grandi di 1Mb in un campo LONGBLOB? Ha forse il limite di 1Mb il campo LONGBLOB? Se si, posso modificare tale limite? Per le immagini inferiori a...
9
by: Eugene | last post by:
I am trying to use db2batch from my XP client against a remote database. And here's what I am getting: C:\work\Tuning\DB2\db2batch> db2batch -d oakl0 -a fs/fs -f db2batch.sql Running in...
4
by: Farooq Khan | last post by:
hi, i'm using CDONTS component for emailing through one of my web service like this // Start of code // 'email' is the CDONTS object name email.send(EmailFrom.ToString(), EmailTo.ToString(),...
5
by: Steven Nagy | last post by:
Hi, I am sending an email in my .NET2.0 web app using: System.Net.Mail.Attachment System.Net.Mail.MailMessage I can successfully send an HTML email with a background image, however that...
2
by: nduerr | last post by:
I have a table with pdf files stored in an attachment data type field in a 2007 Access File. I would like to run a query that would select a group out of this table (easy part) then send the pdf...
1
by: =?Utf-8?B?U2FpIFZhamph?= | last post by:
Hi I am trying to send a .pdf document as an email attachment using net.mail. This email is being sent by a windows service application. After i receive the email, and when i try to open the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.