One thing at a time all the time!

Welcome to Rocteur
Saturday, April 20 2024 @ 01:11 AM CEST

How to send a mail with several attachments

use MIME::Lite

perldoc MIME::Lite

#!/usr/bin/perl -w

use strict;
use MIME::Lite;

### Create a new multipart message:
my $msg = MIME::Lite->new(
From =>'jerry@domain.cc',
To =>'jerry@domain.com',
Cc =>'',
Subject =>'A message with 2 parts...',
Type =>'multipart/mixed'
);

### Add parts (each "attach" has same arguments as "new"):
$msg->attach(Type =>'TEXT',
Data =>"Here's the GIF file you wanted"
);
$msg->attach(Type =>'image/gif',
Path =>'bide_logo.gif',
Filename =>'bide_logo.gif',
Disposition => 'attachment'
);

$msg->send;

FAQ Manager » Perl » How to send a mail with several attachments