I can't say that I'm absolutley
proud of this code, but it has been working for over a year now... This is my pseudo-mailing list of people that like to receive fortune via email instead of on the console. Better show the code instead of trying to explain. Its extremely simple:
#!/usr/bin/perl
# Fortune via mail
my ($recipients,$fortune,@recipients);
# get subscribers
open(READ,'/home/bbq/fortune.recipients.txt') || die();
while(<READ>) {
chop;
$recipients = push(@recipients,$_);
}
close(READ);
# get fortune
$fortune = `fortune`;
# compose + send the email
open(PIPE,"|/usr/lib/sendmail -t");
print PIPE "From: bbq\@bbq.warp.psi.br (BBQ's Fortune Telling Machine)
+\n";
print PIPE "To: bbq\@zaz.com.br (A bunch of geeks...)\n";
print PIPE "Bcc: ".join(', ',@recipients)."\n";
print PIPE "Subject: And your fortune for today is...\n\n";
print PIPE "$fortune\n";
print PIPE "Have a nice day!\n";
print PIPE "$recipients people on list.\n";
close(PIPE);
... there and now I have this script running from my cron everyday at 6:00am (-300 GMT). :o)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.