#!/bin/csh -f # javamail # ------------------------------------------------------------------------------ # Shell script to send an e-mail message using an SMTP server, port, username, # password, and other relatively static parameters, specified as environment # variables, but accepting the more dynamic To:, From:, CC:, Subject and body # as command line options and standard input. # ------------------------------------------------------------------------------ # Usage: See Usage section below or run with no arguments to see usage. # Assumptions: # Effects: # - Sends an e-mail message. # Notes: # Implementation Notes: # Portability Issues: # Revision History: # $Log$ # ------------------------------------------------------------------------------ if ("`printenv SMTP_SERVER`" != "") then set smtp_server_option="-server $SMTP_SERVER" else set smtp_server_option= endif if ("`printenv SMTP_PORT`" != "") then set smtp_port_option="-port $SMTP_PORT" else set smtp_port_option= endif if ("`printenv SMTP_USER`" != "") then set smtp_user_option="-user $SMTP_USER" else set smtp_user_option= endif if ("`printenv SMTP_PW`" != "") then set smtp_pw_option="-pw $SMTP_PW" else set smtp_pw_option= endif if ("`printenv SMTP_RETRY_MAX`" != "") then set smtp_retry_max_option="-retrymax $SMTP_RETRY_MAX" else set smtp_retry_max_option= endif if ("`printenv SMTP_RETRY_DELAY`" != "") then set smtp_retry_delay_option="-retrydelay $SMTP_RETRY_DELAY" else set smtp_retry_delay_option= endif java -classpath /Users/fred/fred/lib/javamail.jar:/Users/fred/fred/lib/bristle.jar:/Users/fred/fred/lib/mail.jar:/Users/fred/fred/lib/activation.jar com.bristle.javaapps.javamail.JavaMail $smtp_server_option $smtp_port_option $smtp_user_option $smtp_pw_option $smtp_retry_max_option $smtp_retry_delay_option $*:q exit $status tell.bat: @echo off rem Simple BAT file to be called by AT command. Don't use env vars that may rem not be defined. if "%MY_DRV%" == "" set MY_DRV=c: if "%HOME%" == "" set HOME=%MY_DRV%\fred if "%BAT%" == "" set BAT=%HOME%\bat if "%1" == "" goto USAGE if "%1" == "-?" goto USAGE rem Old way, before I improved logging of javamail.java. rem echo Starting... >> %MY_DRV%\tell.log rem echo call %BAT%\javamail -continue -verbose -from fred@bristle.com -to %1 -subj "%2 %3 %4 %5 %6 %7 %8 %9" >> %MY_DRV%\tell.log rem call %BAT%\javamail -continue -verbose -from fred@bristle.com -to %1 -subj "%2 %3 %4 %5 %6 %7 %8 %9" < nul >> %MY_DRV%\tell.log 2>&1 rem echo ...Ending >> %MY_DRV%\tell.log if "%1" == "-verbose" goto :VERBOSE call %BAT%\javamail -continue -from fred@bristle.com -to %1 -subj "%2 %3 %4 %5 %6 %7 %8 %9" < nul goto EXIT :VERBOSE shift call %BAT%\javamail -continue -verbose -from fred@bristle.com -to %1 -subj "%2 %3 %4 %5 %6 %7 %8 %9" < nul goto EXIT :USAGE echo Usage: %0 [options] email_address subject_line_words echo Where options can be: echo -verbose echo Examples: %0 fred@bristle.com This is a test... echo Examples: %0 -verbose fred@bristle.com This is a test... goto EXIT :EXIT pingfred.bat: @echo off rem Simple BAT file to be called by AT command. Don't use env vars that may rem not be defined. if "%MY_DRV%" == "" set MY_DRV=c: if "%HOME%" == "" set HOME=%MY_DRV%\fred if "%BAT%" == "" set BAT=%HOME%\bat rem Note: It's OK to pass more than 9 params to tell.bat because it uses shift rem to shift them after checking for -verbose. setenv SMTP_SERVER bristle.com setenv SMTP_PORT 8325 rem -- setenv SMTP_USER fred@bristle.com rem -- setenv SMTP_PW my_password setenv SMTP_RETRY_MAX 10 setenv SMTP_RETRY_DELAY 1 rem -- @call %BAT%\tell.bat -verbose fred@stluka.com PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to fred@stluka.com... >> %MY_DRV%\pingfred.log 2>&1 rem -- @call %BAT%\tell.bat -verbose stluka@voicenet.com PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to stluka@voicenet.com... >> %MY_DRV%\pingfred.log 2>&1 @call %BAT%\tell.bat -verbose fred@bristle.com PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to fred@bristle.com... >> %MY_DRV%\pingfred.log 2>&1 rem -- @call %BAT%\tell.bat -verbose stluka@comcast.net PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to stluka@comcast.net... >> %MY_DRV%\pingfred.log 2>&1 rem -- @call %BAT%\tell.bat -verbose FredStluka@gmail.com PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to FredStluka@gmail.com... >> %MY_DRV%\pingfred.log 2>&1 unset SMTP_SERVER unset SMTP_PORT unset SMTP_USER unset SMTP_PW unset SMTP_RETRY_MAX unset SMTP_RETRY_DELAY rem -- Wait 5 minutes to avoid a flurry of sends to different SMTP servers, rem -- which could look like spam to Comcast, causing them to block port 25. call %BAT%\sleep 300000 setenv SMTP_SERVER smtp.bristle.com setenv SMTP_PORT 587 rem -- setenv SMTP_USER fred@bristle.com rem -- setenv SMTP_PW my_password setenv SMTP_RETRY_MAX 10 setenv SMTP_RETRY_DELAY 1 rem -- @call %BAT%\tell.bat -verbose fred@stluka.com PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to fred@stluka.com... >> %MY_DRV%\pingfred.log 2>&1 rem -- @call %BAT%\tell.bat -verbose stluka@voicenet.com PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to stluka@voicenet.com... >> %MY_DRV%\pingfred.log 2>&1 @call %BAT%\tell.bat -verbose fred@bristle.com PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to fred@bristle.com... >> %MY_DRV%\pingfred.log 2>&1 rem -- @call %BAT%\tell.bat -verbose stluka@comcast.net PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to stluka@comcast.net... >> %MY_DRV%\pingfred.log 2>&1 rem -- @call %BAT%\tell.bat -verbose FredStluka@gmail.com PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to FredStluka@gmail.com... >> %MY_DRV%\pingfred.log 2>&1 unset SMTP_SERVER unset SMTP_PORT unset SMTP_USER unset SMTP_PW unset SMTP_RETRY_MAX unset SMTP_RETRY_DELAY rem -- Wait 5 minutes to avoid a flurry of sends to different SMTP servers, rem -- which could look like spam to Comcast, causing them to block port 25. call %BAT%\sleep 300000 setenv SMTP_SERVER smtp.comcast.net setenv SMTP_PORT 587 setenv SMTP_USER stluka@comcast.net setenv SMTP_PW brivntco setenv SMTP_RETRY_MAX 10 setenv SMTP_RETRY_DELAY 5 rem -- @call %BAT%\tell.bat -verbose fred@stluka.com PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to fred@stluka.com... >> %MY_DRV%\pingfred.log 2>&1 rem -- @call %BAT%\tell.bat -verbose stluka@voicenet.com PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to stluka@voicenet.com... >> %MY_DRV%\pingfred.log 2>&1 @call %BAT%\tell.bat -verbose fred@bristle.com PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to fred@bristle.com... >> %MY_DRV%\pingfred.log 2>&1 rem -- @call %BAT%\tell.bat -verbose stluka@comcast.net PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to stluka@comcast.net... >> %MY_DRV%\pingfred.log 2>&1 rem -- @call %BAT%\tell.bat -verbose FredStluka@gmail.com PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to FredStluka@gmail.com... >> %MY_DRV%\pingfred.log 2>&1 unset SMTP_SERVER unset SMTP_PORT unset SMTP_USER unset SMTP_PW unset SMTP_RETRY_MAX unset SMTP_RETRY_DELAY rem -- Wait 5 minutes to avoid a flurry of sends to different SMTP servers, rem -- which could look like spam to Comcast, causing them to block port 25. call %BAT%\sleep 300000 setenv SMTP_SERVER smtp.stluka.com setenv SMTP_PORT 587 rem -- setenv SMTP_USER fred@stluka.com rem -- setenv SMTP_PW my_password setenv SMTP_RETRY_MAX 10 setenv SMTP_RETRY_DELAY 1 rem -- @call %BAT%\tell.bat -verbose fred@stluka.com PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to fred@stluka.com... >> %MY_DRV%\pingfred.log 2>&1 rem -- @call %BAT%\tell.bat -verbose stluka@voicenet.com PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to stluka@voicenet.com... >> %MY_DRV%\pingfred.log 2>&1 @call %BAT%\tell.bat -verbose fred@bristle.com PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to fred@bristle.com... >> %MY_DRV%\pingfred.log 2>&1 rem -- @call %BAT%\tell.bat -verbose stluka@comcast.net PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to stluka@comcast.net... >> %MY_DRV%\pingfred.log 2>&1 rem -- @call %BAT%\tell.bat -verbose FredStluka@gmail.com PingTest %1 from %COMPUTERNAME% via %SMTP_SERVER%:%SMTP_PORT% to FredStluka@gmail.com... >> %MY_DRV%\pingfred.log 2>&1 unset SMTP_SERVER unset SMTP_PORT unset SMTP_USER unset SMTP_PW unset SMTP_RETRY_MAX unset SMTP_RETRY_DELAY