NAME
Mail::Send::Loop - Perl extension for sending emails that attach each file in a specified folder and loop a set of users
SYNOPSIS
use strict;
use Mail::Send::Loop;
my @sender = ('Acting@netdlp.com', 'Actors@netdlp.com', 'Administrator@netdlp.com');
my @rpient = ('tiger@freedom.net', 'lion@freedom.net');
my $mailer = Mail::Send::Loop->new(
mail_host => '127.0.0.1',
mail_port => 25,
mail_mode => '1tom',
greeting => 'www.com',
senders => \@sender,
recipients => \@rpient,
mail_count => 8,
);
my $email_body = &getMIME();
$mailer->setDebug(1);
my $ret = $mailer->sendMail_LoopAllUsers(
mail_body => $email_body,
mail_mode => '1to1',
mail_count => 3,
);
print " $ret mails sent\n";
$ret = $mailer->sendMail_AllFilesInFolder(
mail_folder => 'test_emails',
mail_mode => '1to1',
mail_subject => "blabla...",
mail_txt_body=> "7777",
greetings => "ccc.com",
mail_count => 2,
);
print $mailer->emailMode() . "\n";
print " $ret mails sent\n";
sub getMIME(){
return qq(MIME-Version: 1.0
Content-Transfer-Encoding: binary
Content-Type: multipart/mixed; boundary="_----------=_128097394742080"
X-Mailer: MIME::Lite 3.027 (F2.76; T1.30; A2.06; B3.08; Q3.08)
Date: Wed, 4 Aug 2010 19:05:47 -0700
From: jkang\@freedom.net
To: bill\@freedom.net
Subject: A message with 2 parts ...
This is a multi-part message in MIME format.
--_----------=_128097394742080
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
Here's the attachment file(s) you wanted
--_----------=_128097394742080
Content-Disposition: attachment; filename="head.gif"
Content-Transfer-Encoding: base64
Content-Type: image/gif; name="head.gif"
R0lGODlhUABQAPcAABgICC9vcTw6MC+jtKlvVHg7KcGLayQiG4BXRLR2bGEj
...
--_----------=_128097394742080--
);
}
DESCRIPTION
The Module is designed to stress any MTA with different files, senders and recipients.
METHODS
new
my $mailer = Mail::Send::Loop->new(option => 'value', ...);
Create an Email Client. Other functions can override some parameters.
Options:
debug
Print all SMTP conversation
mail_host
MTA's IP
mail_port
MTA's Port. The default port is 25 if not given.
greeting
HELO greeting. The default domain is 'test.net' if not given.
senders
Users set for 'MAIL FROM'. It takes an ARRAY reference.
recipients
Users set for 'RCPT TO'. It takes an ARRAY reference.
mail_mode
1tom: One TCP connection to MTA is used to send MANY emails.
1to1: One TCP connection to MTA is used to send ONE email.
mail_count
Stop sending email after specified number of emails sent
-1: Keep sending emails endlessly
setDebug
$mailer->setDebug(1);
1/0: Enable/Disable SMTP conversation information
emailMode
$mailer->emailMode()
Print current email Mode or Set it to 1to1/1tom.
sendMail_AllFilesInFolder
$mailer->sendMail_AllFilesInFolder(option => 'value', ...);
Options:
mail_folder
All files in this specified folder will be sent one by one as an attachment. EML file is sent as-it. Other files will be MIME-encrypted first based on LWP/media.types, and then sent out. Each email has only One attachment.
mail_mode
1tom: One TCP connection to MTA is used to send MANY emails.
1to1: One TCP connection to MTA is used to send ONE email.
mail_subject
Static subject for each email
mail_txt_body
Static email text body
greeting
HELO greeting
senders
Users set for 'MAIL FROM'. It takes an ARRAY reference.
recipients
Users set for 'RCPT TO'. It takes an ARRAY reference.
mail_count
Stop sending email after specified number of emails sent
sendMail_LoopAllUsers
$mailer->sendMail_LoopAllUsers(option => 'value', ...);
Send SAME email to all users.
Options:
mail_body
It takes text string that can be prepared MIME-encrypted email content.
mail_mode
1tom: One TCP connection to MTA is used to send MANY emails.
1to1: One TCP connection to MTA is used to send ONE email.
greeting
HELO greeting
senders
Users set for 'MAIL FROM'. It takes an ARRAY reference.
recipients
Users set for 'RCPT TO'. It takes an ARRAY reference.
mail_count
Stop sending email after specified number of emails sent
SEE ALSO
Please, see MIME::Lite.
AUTHOR
Jing Kang <kxj@hotmail.com>
COPYRIGHT AND LICENSE
Copyright (C) 2010 by jkang
This library is free software.