473,387 Members | 1,573 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,387 software developers and data experts.

Sending mail with an attachment

p2
Hi,

I know how to send a file as an attachment when the file is in my file
system.

Now I want to send data as attachment without saving it to the
filesystem first.

Under UNIX shell what I do is uuencode and dump the output at the end
of the 'data' part of the message.

How can I convert the string to an attachment without the mediation of
the filesystem?

(The goal is to allow users to request data by email)

Thank you all,

Aug 8 '05 #1
5 1550
*** p2 wrote/escribió (8 Aug 2005 01:00:04 -0700):
Now I want to send data as attachment without saving it to the
filesystem first.

Under UNIX shell what I do is uuencode and dump the output at the end
of the 'data' part of the message.

How can I convert the string to an attachment without the mediation of
the filesystem?


So, your data is not in a file and apparently it's not in a string (or you
wouldn't be asking). Where is it then?
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Aug 8 '05 #2
Hello,

I know that if you send an attachment the file will transformed to
binary data and encoded in some sort of way. If the email has the
neccesary headers (MIME-Version: 1.0\r\nContent-type: multipart/mixed;
boundary=9312495342k5hk45h8\r\n) and is split in to two parts (one
text, one attachment) by the boundary.
Then give the attachment part the right headers (Content type=<type of
file>; name=<filename>\r\nContent-transfer-encoding:
base64\r\nContent-disposition: attachment; filename=<filename>\r\n\r\n)
followed by the data (chunk_split(base64encode($data)))

These are the steps you will have to take.

Good luck!

Aug 8 '05 #3
p2 wrote:
Hi,

I know how to send a file as an attachment when the file is in my file
system.

Now I want to send data as attachment without saving it to the
filesystem first.

Under UNIX shell what I do is uuencode and dump the output at the end
of the 'data' part of the message.

How can I convert the string to an attachment without the mediation of
the filesystem?

(The goal is to allow users to request data by email)

Thank you all,


I have a php class (source:
http://www.ugrad.cs.ubc.ca/~y8r3/code/mailer.html) to handle sending
multi-part emails with attachments. It does not do what you are
looking for currently, but the necessary changes are pretty trivial.
You will, of course, need to know the content-type of your string,
etc.

I'm not sure if this will be helpful for you or not, but it might at
least provide a starting point if you need one.

-Ben

Aug 8 '05 #4
p2
Thank you all,

Eventually I did is:

$mail_msg .= "\nbegin 644 $filename\n";
$mail_msg .= convert_uuencode("$string");
$mail_msg .= "\n`\nend";

But this work with PHP5 only. The function convert_uuencode is new.

Still working on a solution for PHP4.

Thanks.

Aug 8 '05 #5
p2 (an*****@gmail.com) wrote:
: Thank you all,

: Eventually I did is:

: $mail_msg .= "\nbegin 644 $filename\n";
: $mail_msg .= convert_uuencode("$string");
: $mail_msg .= "\n`\nend";

: But this work with PHP5 only. The function convert_uuencode is new.

It also assumes that the mail client does uudecoding. Since uu(en/de)code
is not a standard, you cannot be sure it will always do what you wish.

If possible you should use MIME encoding.
--

This space not for rent.
Aug 8 '05 #6

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

Similar topics

0
by: Dragos Marian Barbu | last post by:
Recently I tried to develop a function to help me sending e-mail messages with more than one attachment. Everything is working OK when I am sebding messages with one attachment, but when I try to...
6
by: Anuradha | last post by:
Dear All How can i send mails using vb.net Thanx all
6
by: rekaeps | last post by:
We are developing an ASP.NET 2.0 (C#) application, and I'm having troubles sending e-mail from the server when accessing the web site from a separate client computer. Also, in the same scenario,...
0
by: rekaeps | last post by:
We are developing an ASP.NET 2.0 (C#) application, and I'm having troubles sending e-mail from the server when accessing the web site from a separate client computer. Also, in the same scenario,...
3
by: dnuos | last post by:
We are developing an ASP.NET 2.0 (C#) application, and I'm having troubles sending e-mail from the server when accessing the web site from a separate client computer. Here's some details: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.