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

I am trying to send an email through my PERL Script, but I need to add an attachment to it. I need some help on how to do that. I still a beginner with all this. Chris

Replies are listed 'Best First'.
Re: Sending email with attachment
by ikegami (Patriarch) on Jun 14, 2005 at 19:55 UTC
    Check out MIME::Lite
    ### Start with a simple text message: $msg = MIME::Lite->new( From => 'me@myhost.com', To => 'you@yourhost.com', Cc => 'some@other.com, some@more.com', Subject => 'A message with 2 parts...', Type => 'TEXT', Data => "Here's the GIF file you wanted", ); ### Attach a part... the make the message a multipart automatically: $msg->attach( Type => 'image/gif', Path => 'aaa000123.gif', Filename => 'logo.gif', ); ### Send in the "best" way (the default is to use "sendmail"): $msg->send;
      MIME::Lite is great...and if you add MIME::Types you can use

      Type => 'AUTO'
      in your code. This tells MIME::Lite to make a best guess about your attachment types - assuming you're going to have more than one type of attachment (.xls, .csv, .gif, etc).

      Jack

Re: Sending email with attachment
by davidrw (Prior) on Jun 14, 2005 at 19:53 UTC
    What is your current method/attempt (working or otherwise) to send mail?
    Mail::Sendmail can do attachments (see it's faq for examples), and i'm sure there's a bunch of other Mail and MIME modules on CPAN that can help, too.
Re: Sending email with attachment
by djohnston (Monk) on Jun 14, 2005 at 21:14 UTC
    I dreaded the day I would have to write an email/attachment app, but when the need finally arose, MIME::Lite made it fairly painless.
Re: Sending email with attachment
by Transient (Hermit) on Jun 14, 2005 at 19:51 UTC
    How are you sending the email? What OS?
Re: Sending email with attachment
by marto (Cardinal) on Jun 14, 2005 at 19:52 UTC
    Hi,

    Could you post your Perl script so we can see what you have already?

    Cheers,

    Martin