PDF BLOB to Email

PDF BLOB to Email

am 11.05.2006 15:21:07 von Adrian Bruce

Hi

I have pdf's stored as a blob in a MySQL database, how can i set a
script (PHP obviously!) to email these blobs as pdf files. The only way
i can think of at the moment is to write them to disk and then attach
them to the mail before sending it. This doesn't seem that efficient
but perhaps it is the only way??

Any help greatly Appreciated

Ade

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

Re: PDF BLOB to Email

am 11.05.2006 15:31:03 von mlists

Adrian Bruce wrote:
> Hi

Hello,

> I have pdf's stored as a blob in a MySQL database, how can i set a
> script (PHP obviously!) to email these blobs as pdf files. The only way

No, not "Obviously", PHP is not well suited for many tasks (or has a
high cost to get the suit tailored) :)

If you branch out you'll find a whole world of alternatives that are
easier to code and maintain server wise. All without the onslaught of
PHP security vulnerabilities and performance bloats.

> i can think of at the moment is to write them to disk and then attach
> them to the mail before sending it. This doesn't seem that efficient
> but perhaps it is the only way??

Nope, its fine to attach it from a variable, in fact an example of how
to do just that can be found at

http://search.cpan.org/perldoc?Mail::Sender::Easy

under the "EXAMPLE" header.

you'd simply:

my($pdf_guts) = $dbh->selectrow_array(q{SELECT pdf_guts FROM pdf_store
WHERE id = '123'}); # http://search.cpan.org/perldoc?DBI

PHP's mail() is a lame lame function with limited ability and even
higher hackability, don't use it.

HTH :)

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

Re: PDF BLOB to Email

am 11.05.2006 15:31:41 von Chris Smith

On 5/11/06, Adrian Bruce wrote:
> Hi
>
> I have pdf's stored as a blob in a MySQL database, how can i set a
> script (PHP obviously!) to email these blobs as pdf files. The only way
> i can think of at the moment is to write them to disk and then attach
> them to the mail before sending it. This doesn't seem that efficient
> but perhaps it is the only way??

You'll need to get the pdf in memory then use chunk_split
(http://au.php.net/chunk_split) to split it up..

Even though phpmailer reads them from the filesystem, it should give
you an idea on how to attach docs: http://phpmailer.sourceforge.net

--=20
Postgresql & php tutorials
http://www.designmagick.com/

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

Re: PDF BLOB to Email

am 11.05.2006 15:39:33 von Adrian Bruce

[snip]
No, not "Obviously", PHP is not well suited for many tasks (or has a
high cost to get the suit tailored) :)
[/snip]

"Obviously " because i am posting to a PHP list, numpty! but thank you
for the recommendation anyway.

JupiterHost.Net wrote:
>
>
> Adrian Bruce wrote:
>> Hi
>
> Hello,
>
>> I have pdf's stored as a blob in a MySQL database, how can i set a
>> script (PHP obviously!) to email these blobs as pdf files. The only way
>
> No, not "Obviously", PHP is not well suited for many tasks (or has a
> high cost to get the suit tailored) :)
>
> If you branch out you'll find a whole world of alternatives that are
> easier to code and maintain server wise. All without the onslaught of
> PHP security vulnerabilities and performance bloats.
>
>> i can think of at the moment is to write them to disk and then attach
>> them to the mail before sending it. This doesn't seem that efficient
>> but perhaps it is the only way??
>
> Nope, its fine to attach it from a variable, in fact an example of how
> to do just that can be found at
>
> http://search.cpan.org/perldoc?Mail::Sender::Easy
>
> under the "EXAMPLE" header.
>
> you'd simply:
>
> my($pdf_guts) = $dbh->selectrow_array(q{SELECT pdf_guts FROM
> pdf_store WHERE id = '123'}); # http://search.cpan.org/perldoc?DBI
>
> PHP's mail() is a lame lame function with limited ability and even
> higher hackability, don't use it.
>
> HTH :)
>

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

Re: PDF BLOB to Email

am 11.05.2006 16:01:26 von mlists

Adrian Bruce wrote:

> [snip]
> No, not "Obviously", PHP is not well suited for many tasks (or has a
> high cost to get the suit tailored) :)
> [/snip]
>
> "Obviously " because i am posting to a PHP list, numpty! but thank you
> for the recommendation anyway.

Obvious in that sense sure ,but just pointing out that there are much
much much better alternatives to PHP to do your Database-to-web task.

Most PHP folks have this image that since its so shiny its just the best
which in fact is the opposite: the nice graphic designers that skin PHP
projects do very well (images/css/html which are all independant of
PHP), but its like dressing up a turd in silk, its still crap underneath :)

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

Re: PDF BLOB to Email

am 11.05.2006 16:09:44 von dpgirago

> Adrian Bruce wrote:
>
>> [snip]
>> No, not "Obviously", PHP is not well suited for many tasks (or has a
>> high cost to get the suit tailored) :)
>> [/snip]
>>
>> "Obviously " because i am posting to a PHP list, numpty! but thank you

>> for the recommendation anyway.

> Obvious in that sense sure ,but just pointing out that there are much
> much much better alternatives to PHP to do your Database-to-web task.
>
> Most PHP folks have this image that since its so shiny its just the best
> which in fact is the opposite: the nice graphic designers that skin PHP
> projects do very well (images/css/html which are all independant of
> PHP), but its like dressing up a turd in silk, its still crap underneath
:)

A bit indelicate for posting to a PHP list, don't you think? If that's your
opinion, please unsubscibe from the list. There's enough negavitiy swirling
around the world as it it.

David

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

Re: PDF BLOB to Email

am 11.05.2006 17:51:44 von mlists

>>Most PHP folks have this image that since its so shiny its just the best
>>which in fact is the opposite: the nice graphic designers that skin PHP
>>projects do very well (images/css/html which are all independant of
>>PHP), but its like dressing up a turd in silk, its still crap underneath
>
> :)
>
> A bit indelicate for posting to a PHP list, don't you think? If that's your

Not if there is a better solution for what he's asking how to do :) (Q:
how do I get a nail driven in with a wrench A: use a hammer)

> opinion, please unsubscibe from the list. There's enough negavitiy swirling
> around the world as it it.

I do understand how a PHP list would be offended by negative comments
about PHP and I apologize.

However the fact remains, that the principles I stated are very true and
using PHP for anything but the simplest tasks (unless you have a
dedicated server with one admin user and one normal user (IE one
website), tops, to run your major app on) is a really really bad idea
and its starting to bite people.

No offence all :) I love everyone and I wish the best in all your
programming endevors.

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

Re: PDF BLOB to Email

am 11.05.2006 18:44:04 von Edward Vermillion

On May 11, 2006, at 10:51 AM, JupiterHost.Net wrote:

>>> Most PHP folks have this image that since its so shiny its just
>>> the best
>>> which in fact is the opposite: the nice graphic designers that
>>> skin PHP
>>> projects do very well (images/css/html which are all independant of
>>> PHP), but its like dressing up a turd in silk, its still crap
>>> underneath
>> :)
>> A bit indelicate for posting to a PHP list, don't you think? If
>> that's your
>
> Not if there is a better solution for what he's asking how to do :)
> (Q: how do I get a nail driven in with a wrench A: use a hammer)
>
>> opinion, please unsubscibe from the list. There's enough negavitiy
>> swirling
>> around the world as it it.
>
> I do understand how a PHP list would be offended by negative
> comments about PHP and I apologize.
>
> However the fact remains, that the principles I stated are very
> true and using PHP for anything but the simplest tasks (unless you
> have a dedicated server with one admin user and one normal user (IE
> one website), tops, to run your major app on) is a really really
> bad idea and its starting to bite people.

I think you're confusing php (the language) with bad programming
practices (the developers). They aren't the same.

>
> No offence all :) I love everyone and I wish the best in all your
> programming endevors.
>
> --
> 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

Re: PDF BLOB to Email

am 11.05.2006 20:59:31 von mlists

> I think you're confusing php (the language) with bad programming
> practices (the developers). They aren't the same.

A true enough statement, except what i am referring to is that PHP (the
language) lends itself to bad practice and has extremely bad security
issues (example: your config info is usually in world readable files so
*anyone* can get your database connection info and have there way with
your data) and has general unnecessary administration concerns (to add
support for the simplest thing can break apache or PHP for the entire
server, yeah yeah PECL, PEAR, etc whatever, they're crap).

Or why not just

touch ~/php.ini

and all your "secure" php.ini settings are turned right off (yeah yeah
until you do Zend Optimizer's php.ini, but again more bloat for your buck)

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

Re: PDF BLOB to Email

am 11.05.2006 21:36:57 von dpgirago

>> I think you're confusing php (the language) with bad programming
>> practices (the developers). They aren't the same.

> A true enough statement, except what i am referring to is that PHP (the
> language) lends itself to bad practice and has extremely bad security
> issues (example: your config info is usually in world readable files so
> *anyone* can get your database connection info and have there way with
> your data) and has general unnecessary administration concerns (to add
> support for the simplest thing can break apache or PHP for the entire
> server, yeah yeah PECL, PEAR, etc whatever, they're crap).

> Or why not just

> touch ~/php.ini

> and all your "secure" php.ini settings are turned right off (yeah yeah
> until you do Zend Optimizer's php.ini, but again more bloat for your
buck)

At the risk of extending empathy where none is given, perhaps you should
tell us what experiences have led to your negativism. You've been a
subscriber to this list for quite a while, and as far as I can remember,
your posts have never been critical of the language.

Surely something must have happened...

David

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

Re: PDF BLOB to Email

am 12.05.2006 00:59:15 von mlists

> At the risk of extending empathy where none is given, perhaps you should

I do appreciate that thanks :)

> tell us what experiences have led to your negativism. You've been a
> subscriber to this list for quite a while, and as far as I can remember,
> your posts have never been critical of the language.
>
> Surely something must have happened...

Well, its a long story, actually many ;p

I'll break it up in categories and summarize, and I will attempt to be
more positive ;p

a) development:
- no structure, no CPAN
- random DB funtionality different combinations of --with-mysql
--with-mysqli on versions 4.x and 5.x all behave differently and take
different args
- likely to not run the same on the same server

= More expensive to develop and maintain

b) resources:
- php *has* to run under apache and optional "optomizers" because
its soooooooo huge and hoggy

= more expensive to run

c) administration:
- add simple "foo" funtionality you might break apache and you may
break all PHP scripts
- more support for end user since the user's script that worked on
the last server doesn't work on this one (which takes back to the simple
functionality adding bit above)

= more expensive to operate

d) security:
- config files are generally world readable (IE anyone on the server
can get to your authentication info and have complete access to your data)
- directories are generally world writable (IE people ahve uploaded
ISOs and stolen bandwidth from other accounts)
- php.ini can be overridden so its pointless
- I've seen root kits and other malciouse stuff uploaded to
"protected" places via the web (IE phpbb patch google attack)
- SQL injections and other input attacks because some feature is
assumed to be on when it isn;t so the protection never gets applied

= much more expensive (lost customers, time, etc)


yes you can have this with any langauge given a bad programmer but with
PHP you have an inherently flawed system that can unexpected overcome a
good programmer.

The thing that reeeeaaallly irks me is that the general vibe is:

"PHP looks nice so it must be nice" when its simply good graphic
design covering many hidden dangers and all funtionality and more can be
had easier and without all the fuss with so many other technologies

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

Re: PDF BLOB to Email

am 12.05.2006 01:08:18 von Bastien Koert

I'd say a lot of it has to do with poor hosting configuration. But any
language that has evolved as much as PHP over the last few years will have
its issues...

take .net, same shit happens there too...whether you want to compare asp.net
to classic asp or vb.net with vb6....much functionality changed and much of
it not backwards compatible.

my 2 cents,

Bastien

>From: "JupiterHost.Net"
>To: php-db@lists.php.net
>Subject: Re: [PHP-DB] PDF BLOB to Email
>Date: Thu, 11 May 2006 17:59:15 -0500
>
>
>>At the risk of extending empathy where none is given, perhaps you should
>
>I do appreciate that thanks :)
>
>>tell us what experiences have led to your negativism. You've been a
>>subscriber to this list for quite a while, and as far as I can remember,
>>your posts have never been critical of the language.
>>
>>Surely something must have happened...
>
>Well, its a long story, actually many ;p
>
>I'll break it up in categories and summarize, and I will attempt to be more
>positive ;p
>
>a) development:
> - no structure, no CPAN
> - random DB funtionality different combinations of --with-mysql
>--with-mysqli on versions 4.x and 5.x all behave differently and take
>different args
> - likely to not run the same on the same server
>
>= More expensive to develop and maintain
>
>b) resources:
> - php *has* to run under apache and optional "optomizers" because its
>soooooooo huge and hoggy
>
>= more expensive to run
>
>c) administration:
> - add simple "foo" funtionality you might break apache and you may
>break all PHP scripts
> - more support for end user since the user's script that worked on the
>last server doesn't work on this one (which takes back to the simple
>functionality adding bit above)
>
>= more expensive to operate
>
>d) security:
> - config files are generally world readable (IE anyone on the server
>can get to your authentication info and have complete access to your data)
> - directories are generally world writable (IE people ahve uploaded
>ISOs and stolen bandwidth from other accounts)
> - php.ini can be overridden so its pointless
> - I've seen root kits and other malciouse stuff uploaded to "protected"
>places via the web (IE phpbb patch google attack)
> - SQL injections and other input attacks because some feature is
>assumed to be on when it isn;t so the protection never gets applied
>
>= much more expensive (lost customers, time, etc)
>
>
>yes you can have this with any langauge given a bad programmer but with PHP
>you have an inherently flawed system that can unexpected overcome a good
>programmer.
>
>The thing that reeeeaaallly irks me is that the general vibe is:
>
> "PHP looks nice so it must be nice" when its simply good graphic design
>covering many hidden dangers and all funtionality and more can be had
>easier and without all the fuss with so many other technologies
>
>--
>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

Re: PDF BLOB to Email

am 13.05.2006 22:54:08 von Michelle Konzack

Am 2006-05-11 14:21:07, schrieb Adrian Bruce:
> Hi
>
> I have pdf's stored as a blob in a MySQL database, how can i set a
> script (PHP obviously!) to email these blobs as pdf files. The only way
> i can think of at the moment is to write them to disk and then attach
> them to the mail before sending it. This doesn't seem that efficient
> but perhaps it is the only way??

Whay not create the E-Mail in memory and the echo it into "sendmail -t"

This is what I do...
The temporary files laying around (like after crasches or $USER abort)

Greetings
Michelle Konzack


--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack Apt. 917 ICQ #328449886
50, rue de Soultz MSM LinuxMichi
0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)

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