From: Greg Ercolano <erco@(email surpressed)>
Subject: Re: Customised Donemail?
   Date: Wed, 20 Jun 2007 23:32:06 -0400
Msg# 1589
View Complete Thread (3 articles) | All Threads
Last Next
Dylan Penhale wrote:
Hi there

We want to be able use the donemail command to trigger a command to an external program which would generate and include a URL in the donemail mailout.

Is it possible to customise the done mail template?

	The 'donemail' format is 'fixed'.. however, you can use jobdonecommand
	to send fully customized emails by invoking your own script.

	Perl is pretty good at this; it has the ability to send email
	directly via the SMTP module.

	Or, you can use rushsendmail (see 'rushsendmail -help') to do the
	work for you, as it is a bit easier to use than the perl SMTP module.

	Here's a simple perl script that uses rushsendmail to send a
	customized report.

	To use it, save the perl script somewhere, and setup the job's
	'jobdonecommand' to invoke it with the email addresses to send
	the email to, e.g.:

jobdonecommand perl //yourserver/some/directory/MyCustomDonemail.pl foo@(email surpressed) bar@(email surpressed)

	Here's the script:

---- snip
#!/usr/bin/perl -w

#
# SEND EMAIL TO USER(S) WHEN JOB IS DONE
#
#     Invoke this script via 'jobdonecommand'.
#     Any arguments are treated as email addresses.
#

my $rushdir = ( -d "c:/rush" ) ? "c:/rush" : "/usr/local/rush";
my $rushsendmail = "$rushdir/etc/bin/rushsendmail";

my $from = "rush\@mydomain.com";		# CHANGE THIS TO A VALID RETURN ADDRESS
my $to = join(",", @ARGV);                      # command line args are email addresses
if ( ! defined($to) )
    { print "No email address specified!\n"; exit(1); }

# USE RUSHSENDMAIL TO DELIVER EMAIL
#    See 'rushsendmail -help' for more info
#
open(MAIL, "|$rushsendmail -t -f$from -p25");

# Mail header
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: RUSH JOB $ENV{RUSH_JOBID} DONE\n";
print MAIL "\n";

# Mail message
print MAIL "--- RUSH CUSTOM FRAMES REPORT\n";
print MAIL `rush -lf`;                  # send just the rush -lf report

# Done
close(MAIL);

exit(0);
---- snip

	You can use other scripting languages (CSH, BASH, Python, etc..
	even stinky old DOS Batch), and you can make either simpler
	or more complex reports.

	The error output from the above script will go to the 'jobdonecommand.log'
	in the job's log directory, so you can check for mail delivery errors.

	rushsendmail will use the smtp* settings in the rush.conf file
	to figure out how to send mail via your mail server.

You can add the '-dt' flag (Debug Tcp) to rushsendmail if you need to debug the SMTP transactions with the server; the raw debug output will appear in the jobdonecommand's log. To add the -dt flag, you would change this line in the above:

BEFORE: open(MAIL, "|$rushsendmail -t -f$from -p25");
AFTER: open(MAIL, "|$rushsendmail -dt -t -f$from -p25");
                                  ^^^

From looking at the windows rushsendmail binary it looks as if mailfile is passed to it, but I can't see where that file is located or how it is generated.

	The 'donemail' command sets up the rush daemon to /pipe/ the
	built-in formatted message to rushsendmail, similar to how
	the above script pipes the 'rush -lf' report to it.

	You can't customize the 'donemail' command's messages,
	but you can use jobdonecommand instead to invoke your own
	script to do whatever you want.

	Some folks use this to technique to send simple text messages
	to pagers and cell phones, or email fancy html formatted reports.

[NOTE: this message was edited 07/20/2007 to include 'my $from' in the script,]
[      and also added the info about debugging with the '-dt' flag. -ED       ]

--
Greg Ercolano, erco@(email surpressed)
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)


Last Next