I have been working on a program that should notify me of certain things via email. I seek comments on the solution described in the code below.
There are some restrictions that have brought me to /bin/mail: first, This will run on unix boxes with very little access to any modules that are not already installed. second, sendmail will probably not be available.#!/usr/bin/perl -w # $Id: mailtest.pl,v 1.1 2001/08/10 19:32:21 jamgill Exp $ # this little ditty demonstrates using /bin/mail from # within a perl program. it sends emaill to the address # with a subject line of the program's name and a message # of "hello world" and the date. use strict; my $binmail = "/bin/mail"; my $address = 'my_address@my.corneroftha.net'; my $message; my $subject = $0; ### Main: $message = &generate_message($message); `$binmail -t $address <<STOP Subject: $subject hello world. $message STOP`; print "sent message with subject $0 to $address\n"; ### Subs: sub generate_message { my $timestamp = `date`; return($timestamp); }
And the &generate_message, well ... that's just a placeholder for now.
Any comments on sending mail? Is this the best way to do it? Is this a decent way to do it?
In reply to mail out of /bin/mail by jamgill
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |