Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Sending a variable's content as mail attachment

by sdyates (Scribe)
on Dec 16, 2002 at 20:27 UTC ( [id://220333]=perlquestion: print w/replies, xml ) Need Help??

sdyates has asked for the wisdom of the Perl Monks concerning the following question:

My cgi scripts are served from apache and they are all in perl. Therefore, I cannot use perl to create or write files as apache does nto allow this. I want to be able to use email to send an array, @ARRAY2 as an attachment. However, Net::SMTP does not seem to allow this from the man pages. However, I am using the Net::SMTP for my mail.

Is there a way to trick Net::SMTP to send a scalar as an attachment. All I want to do is send simple plain text, and yes, it needs to be sent as an attachment and not included with in the body

I thought of using system() commands, but that is just a bad patch. And opening up apache more does not seem like a smart solution either. Further, I am convinced that there is a smart way for perl to be able to deliver a solution, just looking for a few thoughts on how to do this

Thanks,
Simon

update (broquaint): title change (was The best way to attach a acalar)

  • Comment on Sending a variable's content as mail attachment

Replies are listed 'Best First'.
Re: The best way to attach a acalar
by Aristotle (Chancellor) on Dec 16, 2002 at 20:38 UTC
    Attachment's are not Net::SMTP's job. You want to check out one of the MIME::* modules - MIME::Lite might be a candidate.

    Makeshifts last the longest.

Re: The best way to attach a acalar
by tachyon (Chancellor) on Dec 16, 2002 at 20:50 UTC

    An 'attachment' exists because of MIME the Multipurpose Internet Mail Extensions. MIME allows you to send an 'attachment' in an email which is essentially a just a plain text data stream. To generate this MIME formatted plain text for transmission by Net::SMTP I suggest you use MIME::Lite or MIME::Entity To see what MIME actually looks like print $msg->as_string if you are following the example code in the modules.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: The best way to attach a acalar
by Ionizor (Pilgrim) on Dec 16, 2002 at 20:34 UTC

    I reviewed the docs for Net::SMTP and it doesn't look like it supports file attachments. I checked around on CPAN and Net::SMTP::Multipart does. I'm not sure if this meets your needs but it's probably worth looking into.

Re: The best way to attach a acalar
by seattlejohn (Deacon) on Dec 17, 2002 at 00:57 UTC
    I believe your fundamental assumption that Apache+perl does not allow you to create or write files is mistaken. (I've certainly done it in the past.) Could you be trying to write files someplace where you don't have the proper permissions? Have you tried creating a writeable directory outside the Apache docroot and creating your files there? What kind of error message are you getting when you try to write the files?

            $perlmonks{seattlejohn} = 'John Clyman';

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://220333]
Approved by erikharrison
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-23 10:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found