I've a script through which i'm trying to send multiple attachments. But the problem is that only a single attachment is being sent.I've tried other methods like MIME::Lite and Net::SMTP, but they are not much helpful as they send the Email into the SPAM/JUNK folder.I am posting my script below kindly help me out. thanx in advance.
#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
use Email::Send;
use Email::Send::Gmail;
use Email::MIME::Creator;
use IO::All;
my $url = "http://abcd.com/search?q=%22MB%22&t=blogs&f=csv";
my $file = "/Users/Abc/Desktop/MB.csv";
my $status = mirror($url,$file);
die "Cannot retrieve $url" unless is_success($status);
my $url1 = "http://abcd.com/search?q=%22M%22&t=microblogs&f=csv";
my $file1 = "/Users/Abc/Desktop/M.csv";
my $status1 = mirror($url1,$file1);
die "Cannot retrieve $url" unless is_success($status1);
my $email = Email::MIME->create(
header => [
From => 'abcd@gmail.com',
To => 'abc1@gmail.com',
Subject => 'ABCD',
],
attributes => [ {
filename =>"MB.csv",
content_type =>"application/csv",
disposition =>"attachment",
Name =>"/Users/Abc/Desktop/MB.csv",
},
body => io( "/Users/Abc/Desktop/MB.csv" )->all,
{
filename =>"M.csv",
content_type =>"application/csv",
disposition =>"attachment",
Name =>"/Users/ab/Desktop/M.csv",
},
body => io( "/Users/Abc/Desktop/M.csv" )->all,
],
);
my $sender = Email::Send->new(
{ mailer => 'Gmail',
mailer_args => [
username => 'abcd@gmail.com',
password => '1234qwerty',
]
}
);
eval { $sender->send($email) };
die "Error sending email: $@" if $@;