[Sig] Mail Client (sender) that can be driven from the command line -- recommendations?
Randy Kramer
rhkramer@fast.net
Mon, 26 Feb 2001 08:06:12 +0000
I have a TWiki partially installed at home. (It is not completely or correctly configured yet.)
It can send email notification of changes (and email notice of successful registration) using a Perl program -- the Perl program formats a message and then issues a command to sendmail.
I'd like to find another (Linux) mail client that can be driven from the command line. Anyone know of any?
I would expect that this ability is not that uncommon -- under Microsoft, Visual Basic programs can call either Outlook or Messenger to send email under program control.
(Sendmail is not configured on this machine, but I can send mail from this machine using any email client configured to use my ISP's smtp account.)
Thanks!
Randy Kramer
PS: For anybody who is really interested:
The mail program is specified in a configuration file like this:
$mailProgram = "/usr/sbin/sendmail -t -oi -oeq";
The mail program is invoked from a Perl subprogram (method?) like this:
sub sendEmail
{
# Format: "From: ...\nTo: ...\nSubject: ...\n\nMailBody..."
my( $mailText) = @_;
if( open( MAIL, "|-" ) || exec "$mailProgram" ) {
print MAIL $mailText;
close( MAIL );
return "OK";
}
return "";
}
In another Perl program, the sendEmail method is invoked like this:
if( ! &wiki::sendEmail( $text ) ) {
print STDERR "- ERROR: TWiki mailnotify can't send mail\n";
$debug && print "- End Twiki.$webName\n";
} else {
$debug && print "- End Twiki.$webName, mail notification sent\n";
}
After several commands to format the message, like this:
$text = &wiki::readTemplate( "mailnotify" );
$text =~ s/%EMAILFROM%/%WIKIWEBMASTER%/go;
$text =~ s/%EMAILTO%/$notifylist/go;
$text =~ s/%EMAILBODY%/$emailbody/go;
$text =~ s/%TOPICLIST%/$topiclist/go;
$text =~ s/%LASTDATE%/&wiki::formatGmTime($prevLastmodify)/geo;
$text = &wiki::handleCommonTags( $text, $topic );