From: Dylan Penhale <dylan@(email surpressed)> Subject: Customised Donemail? Date: Wed, 20 Jun 2007 21:35:49 -0400 |
Msg# 1588 View Complete Thread (3 articles) | All Threads Last Next |
Hi thereWe 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? 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. It looks to be a combination of rush -ljf and rush -lff Is this possible? Regards -- Dylan Penhale Systems Administrator Fuel International 65 King Street Newtown Sydney Australia 2042 p. (Tel# suppressed) f. (Tel# suppressed) m. +61424 655 320 w. www.fuelvfx.com |
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 thereWe 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) |
From: Greg Ercolano <erco@(email surpressed)> Subject: Re: Customised Donemail? Date: Thu, 12 Mar 2015 15:39:57 -0400 |
Msg# 2388 View Complete Thread (3 articles) | All Threads Last Next |
On 06/20/07 20:32, Greg Ercolano wrote: > 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. > # > [..] Would like to update this old thread to include some SSL examples for sending email, as some servers need SSL authentication to send email. In such a case, with perl you can use the Net::SMTP::SSL module, e.g. something like: ---- snip #!/usr/bin/perl # smtp-ssl with auth use warnings; use strict; use Net::SMTP::SSL; # SERVER CONFIG my $server = 'your.smtp.server.com'; my $user = 'authuser@(email surpressed)'; my $pass = 'somepass'; # MESSAGE HEADER INFO my $to = 'them@(email surpressed)'; my $from_name = 'John Q Public'; my $from_email = 'johnq@(email surpressed)'; my $subject = 'Test message'; # CONNECT TO SERVER my $smtps = Net::SMTP::SSL->new($server, Port => 465, DEBUG => 1 ) or warn "$!\n"; defined ($smtps->auth($user, $pass)) or die "Can't authenticate: $!\n"; # SEND MESSAGE $smtps->mail($from_email); $smtps->to($to); $smtps->data(); $smtps->datasend("To: $to\n"); $smtps->datasend("From: \"$from_name\" <$from_email>\n"); $smtps->datasend("Subject: $subject\n"); $smtps->datasend("\n"); # empty line separates header from body $smtps->datasend("Your multiline message goes here.\n"); $smtps->dataend(); $smtps->quit(); print "done\n"; ---- snip See the perl docs for the Net::SMTP::SSL module for more info. And here's a python technique, e.g. ---- snip import smtplib # SERVER server = 'your.server.com' mailuser = 'authuser@(email surpressed)' # if auth needed mailpasswd = 'somepass' # if auth needed # MESSAGE HEADER from_addr = 'us@(email surpressed)' to_addr = 'them@(email surpressed)' subject = 'Test message' msg = "From: %s\nTo: %s\nSubject: %s\n\n" % ( from_addr, to_addr, subject) msg += "Your multiline msg here.\nLine two.\n" # CONNECT TO SERVER, AUTHENTICATE m = smtplib.SMTP_SSL(server, port=465) m.login(mailuser, mailpasswd) # if auth needed m.set_debuglevel(1) # SEND MESSAGE m.sendmail(from_addr, to_addr, msg) m.quit() ---- snip See the python docs for smtplib for more. -- Greg Ercolano, erco@(email surpressed) Seriss Corporation Rush Render Queue, http://seriss.com/rush/ Skype: ercolano77 Tel: (Tel# suppressed)ext.23 Fax: (Tel# suppressed) Cel: (Tel# suppressed) |