I am using a perl script through which i want to send email to multiple users. The Script is working fine for a single user and doing my work fine. But when i want to send the same mail to multiple users, i get errors. I am posting my script below. Kindly help me out.

ORIGINAL SCRIPT :
#!/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 $basefolder = "/Users/Abc/Desktop/"; my $from = "test1\@gmail.com"; my $to = 'test2l\@hotmail.com'; my $subject = "DSMS"; my $url = "http://abc.com/search?q=%22M%22&t=blogs&f=csv"; my $file = $basefolder . "M-B.csv"; my $status = mirror($url,$file); die "Cannot retrieve $url" unless is_success($status); my $url1 = "http://abc.com/search?q=%22M%22&t=microblogs&f=csv"; my $file1 = $basefolder . "M-MB.csv"; my $status1 = mirror($url1,$file1); die "Cannot retrieve $url" unless is_success($status1); my @parts = ( Email::MIME->create( attributes => { filename =>"M-B.csv", content_type =>"application/csv", disposition =>"attachment", Name =>$basefolder . "M-B.csv", }, body => io( $basefolder . "M-B.csv" )->all, ), Email::MIME->create( attributes => { filename =>"M-MB.csv", content_type =>"application/csv", disposition =>"attachment", Name =>$basefolder . "M-MB.csv", }, body => io( $basefolder . "M-MB.csv" )->all, ), ); my $email = Email::MIME->create( header => [ From => $from, To => $to, Subject => $subject, ], parts => [@parts] ); my $sender = Email::Send->new( { mailer => 'Gmail', mailer_args => [ username => 'test1@gmail.com', password => '1234qwerty', ] } ); eval { $sender->send($email) }; die "Error sending email: $@" if $@;

I've tried adding multiple emails to My $to. Besides that i have tried adding a My $to1. i don't want to send them as cc or bcc.

But both of theses did not work for me. Is there an other way. If yes kindly specify. Thanx in advance.

In reply to Email::Mime and Multiple Recipients by Appy16

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.