Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2004
    Posts
    2

    Unanswered: Sending an attachment in a Perl Script

    I'm trying to set up a script that will allow me to send an attachment using sendmail. I think I'm close with using uuencode, but wondering if anyone else has made it work.

    Thanks.

  2. #2
    Join Date
    Jun 2004
    Location
    Nowhere Near You
    Posts
    89
    If all else fails you can always try the Perl Cookbook ...
    Use the MIME::Lite module from CPAN. First, create a MIME::Lite object representing the multipart message:
    Code:
    use MIME::Lite;
    
    $msg=MIME::Lite->new(From    => 'sender@example.com',
                         To      => 'recipient@example.com',
                         Subject => 'Photo',
                         Type    => 'multipart/mixed');
    Then, add content through the attach method:
    Code:
    $msg->attach(Type     => 'image/jpeg',
                 Path     => '/Users/gnat/gnat.jpg',
                 Filename => 'gnat-face.jpg');
    $msg->attach(Type     => 'TEXT',
                 Path     => 'Hopefully this is what you want.');
    Finally, send the message:
    Code:
    $msg->send;

  3. #3
    Join Date
    Jul 2004
    Posts
    2

    Perl Libraries and Modules

    Thanks for the feedback. Doesn't look too complicated, but I've never used the libraries and modules. My friend who helped me get into Perl programming called me a hacker not a programmer. I have the Learning Perl book, but I don't have the Perl Cookbook. I guess I'm going to have to break down and buy the cookbook. I'm going to try and take your code and make it work. I don't see a MIME or Lite library on my 5.00503 version of Perl or in the CPAN directory or in the CPAN.pm library. Anyway maybe it will all work, but I would like to understand what it is doing. I've created my own libraries all of the time using the require fuction and that has worked wonderful, but that is just my own subroutines and I can understand my own code. Anyway thanks for your help and pointing me in the right direction.

  4. #4
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    167
    You can find the MIME::Lite-module at CPAN: http://search.cpan.org/~yves/MIME-Lite-3.01/

    I think using a module like MIME::Liste is the best way of sending a mail. This module takes a lot of work from you.
    board.perl-community.de - The German Perl-Community

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •