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 $@;
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.