Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3845568
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:15:51+00:00 2026-05-19T16:15:51+00:00

I find it hard to believe that this question doesn’t exist on SO, but

  • 0

I find it hard to believe that this question doesn’t exist on SO, but I couldn’t find an instance or one similar for Perl….

Anyway, what Perl module should I use to attach multiple files to an email?

Currently, I’m using this code to send an email with a single attachment, but I couldn’t figure out how to modify it to handle multiple attachments:

my $mail_fh = \*MAIL;
open $mail_fh, "|uuencode $attachment $attachment |mailx -m -s \"$subject\" -r $sender $recipient";
print $mail_fh $message;
close($mail_fh);

Can this code block be modified to handle multiple attachments? Or do I have to use a special module to pull this off? If so, what is the module and how would I script it out?

Thanks for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T16:15:52+00:00Added an answer on May 19, 2026 at 4:15 pm

    I ended up going with an example using MIME::Lite found here

    use MIME::Lite;
    use Getopt::Std;
    
    my $SMTP_SERVER = 'smtp.server.com';             #change
    my $DEFAULT_SENDER = 'default@sender.com';       #change
    my $DEFAULT_RECIPIENT = 'default@recipient.com'; #change
    
    MIME::Lite->send('smtp', $SMTP_SERVER, Timeout=>60);
    
    my (%o, $msg);
    
    # process options
    
    getopts('hf:t:s:', \%o);
    
    $o{f} ||= $DEFAULT_SENDER;
    $o{t} ||= $DEFAULT_RECIPIENT;
    $o{s} ||= 'Files';
    
    if ($o{h} or !@ARGV) {
        die "usage:\n\t$0 [-h] [-f from] [-t to] [-s subject] files ...\n";
    }
    
    # construct and send email
    
    $msg = new MIME::Lite(
        From => $o{f},
        To   => $o{t},
        Subject => $o{s},
        Data => "Data",
        Type => "multipart/mixed",
    );
    
    while (@ARGV) {
      $msg->attach('Type' => 'application/octet-stream',
                   'Encoding' => 'base64',
                   'Path' => shift @ARGV);
    }
    
    $msg->send(  );
    

    example usage:

    ./notify_mime.pl -f cheese -t queso -s subject /home/id/cheeseconqueso/some_dir/example1.xls /home/id/cheeseconqueso/some_other_dir/*.xls
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe this question has been asked before, but I couldn't find it. I am
unfortunately Dreamweaver doesn't support Asp.net mvc, and I find it hard to believe that
I find it hard to believe that I am the only one wondering about
It is hard to find a resource on this without finding Java EE, but
I find it hard to believe I'm the first person to run into this
This is a question I was wondering about for some time now, but couldn't
I can't believe that this hasn't been covered before, but I have been having
I find it hard to find clear examples that would explain how to read
It's not hard to find developers who think cursors are gauche but I am
This should be a fairly simple question. Essentially, I believe there's a good chance

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.