#!/usr/bin/perl
use Mail::Sender
$To = 'email1@example1.com,email2@example2.com';
$sender = new Mail::Sender {
smtp => 'smtp.mailserver.com',
from => 'script@somedomain.com,
});
$Subject = 'This is a Test Email';
$sender->OpenMultipart({
to => "$To",
subject => "$Subject",
});
$Sender->Body;
$Sender->SendLineEnc("Test line 1");
$Sender->SendLineEnc("Test line 2");
$Sender->Attach({
description => 'Test file',
ctype => 'application/pdf',
encoding => 'Base64',
disposition => 'attachment;
filename="File.pdf"; type="PDF"',
file => "$File",
});
$sender->Close();
exit();
####
To = mail1@example1.com,email2@example2.com
####
#!/usr/bin/perl
use Mail::Sender
$TestFile = "../etc/TestFile.conf";
if (!open(TESTFILE,$TestFile)) {
print "ERROR: Unable to open Test File for reading: $TestFile";
exit();
}
foreach $Line () {
if ($Line =~ m/To\s*=\s*(.*)/) {
$To = $1;
print "To = <$To>\n";
}
}
$sender = new Mail::Sender {
smtp => 'smtp.mailserver.com',
from => 'script@somedomain.com,
});
$Subject = 'This is a Test Email';
$sender->OpenMultipart({
to => "\'$To\'",
subject => "$Subject",
});
$Sender->Body;
$Sender->SendLineEnc("Test line 1");
$Sender->SendLineEnc("Test line 2");
$Sender->Attach({
description => 'Test file',
ctype => 'application/pdf',
encoding => 'Base64',
disposition => 'attachment;
filename="File.pdf"; type="PDF"',
file => "$File",
});
$sender->Close();
exit();