Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Welcome to the Monastery
 
PerlMonks  

Re: Dealing with atachments.

by lhoward (Vicar)
on May 17, 2000 at 11:24 UTC ( [id://12064]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Dealing with atachments.

For dealing with attachments use one of the perl MIME modules. I find that MIME::Lite has been strong-enough to do anything I've ever needed with attachments/multipart messages. Here's an example of its usage taken from the MIME::Lite documentation:
use MIME::Lite; # Create a new multipart message: $msg = new MIME::Lite From =>'me@myhost.com', To =>'you@yourhost.com', Cc =>'some@other.com, some@more.com', Subject =>'A message with 2 parts...', Type =>'multipart/mixed'; # Add parts (each "attach" has same arguments as "new"): attach $msg Type =>'TEXT', Data =>"Here's the GIF file you wanted"; attach $msg Type =>'image/gif', Path =>'aaa000123.gif', Filename =>'logo.gif';
Once you have your message constructed with attachments then you need to send it. I prefer to use Net::SMTP to send messages, but there are several other perl modules that can send mail (and several ways of just doing it by hand). If you're already using MIME::Lite the easiest method is to use its built-in send function:
$msg->send;
If you're interested in delving deeper, O'Reilly has a decent book entitled Programming Internet Email that covers most of the interesting internet e-mail protocols and formats. It has a good chapter on e-mail related Perl modules.

Replies are listed 'Best First'.
RE: Re: Dealing with atachments.
by Punto (Scribe) on May 18, 2000 at 07:44 UTC
    That a good example.. thanks..
    And, can I use that module if I get the attachment, to convert it to a file?

    Thanks..

      MIME::Lite can only encode MIME streams. For decoding a MIME message you'll want to use the MIME::Decoder module.
      I just posted this snippet which should help you with decoding and extracting attachments from incoming emails.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://12064]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.