Hi Monks, I'm testing 1-to-1, many-to-one and many-to-many scenarios in SendMail. Meaning, using SendMail modules I need to send mails in this manner using SMTP.


1. One person simultaneously send mail to many ppl - I can use multiple recipient - So I can do this

2. Many to one - I dont know how to many multiple From (around 100000) addresses sending mail to one single To using Fork function.

3. Many to Many - meaning many ppl (say 5000 From) sending mails simultaneously To 5000 ppl using sendmail and fork.

I found Fork, but exactly not sure how to use it. Attached find my code so far i have written. Pls suggest someother better alternative to Fork if any .. The SendMail function works fine.
#!/usr/bin/perl use SendMail; # get the commandline args - FromUserNo, ToUserNo from command my $fromUserNo = $ARGV[0]; my $toUserNo = $ARGV[1]; #setup To and From lists #Build recipient address based on ToUser my $myToUser = "TestTo"; my @ToUser; for( my $i = 1; $i <= $toUserNo; $i++){ $myToUser = "$myToUser"."$i\@xx.yy.com".";"; $myToUser = "TestTo"; } push(@ToUser,$myToUser); #Build Sender address based on FromUser my $myFromUser = "TestFrom"; my @FromUser; for( my $i = 1; $i <= $fromUserNo; $i++){ $myFromUser = "$myFromUser"."$i\@abc.com".";"; $myFromUser = "TestFrom"; } push(@FromUser,$myFromUser); #rules mail server my $server = "xx.yy.com"; $sm = new SendMail($server); #One person sending to multiple receipient at once #for (1..10){ my $pid = fork(); if (not defined $pid) { print "resources avilable, \n"; } elsif ($pid == 0) { $sm->From("test1 <test1\@abc.com>"); $sm->Subject("test"); $sm->To("Rules <rules\@xx.yy.com>"); $sm->setMailBody("test data"); my $attachfile = "C:\\attachmentfile.txt"; $sm->Attach($attachfile); # Check if the mail sent successfully or not. if ($sm->sendMail() != 0) { print $sm->{'error'}."\n"; exit -1; } # Mail sent successfully. print "Mail sent\n\n"; # End child exit(0); } else { print "IM THE PARENT\n"; waitpid($pid,0); } #}

In reply to Mail::SendMail and fork by hiradhu

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.