From: "Dennis G. Wicks" <dgwi...@gmail.com>
Greetings;
I have a couple of directories full of tips, photos, quotes, etc. that I
want to send to a yahoo group that I have.
What I want to do is compose the email, pick an item or two from the
directory, put it in the email & move it/them to a "used" directory and
send the email. I'll fire this off with a crontab.
You can do something like: (untested)
#!/usr/bin/perl
use strict;
use warnings;
use Mail::Builder::Simple;
my $dirpath = "/path/to/the/directory/with/files";
opendir(my $dir, $dirpath);
foreach my $file(readdir $dir) {
next unless -f $file; #Skip the directories
my $mail = Mail::Builder::Simple->new;
$mail->send(
from => 'your_addr...@host.com',
to => 'the_gr...@yahoogroups.com',
subject => "Here is the file $file",
plaintext => "Hi,\n\nHere is the file $file",
attachment => "$dirpath/$file",
);
rename("$dirpath/$file", "/path/to/another/dir/$file");
}
closedir $dir;
__END__
This was just an example. Read
perldoc Mail::Builder::Simple
for more information.
This program sends the messages using Sendmail, but you can use an SMTP host
if you want, and you can also attach more than one file in a message and
many other things.
Octavian
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/