Index: openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl,v diff -u -r1.69 -r1.70 --- openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl 18 Apr 2007 09:13:54 -0000 1.69 +++ openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl 29 Aug 2007 12:59:34 -0000 1.70 @@ -13,81 +13,8 @@ package require base64 2.3.1 namespace eval acs_mail_lite { - #--------------------------------------- - ad_proc -public with_finally { - -code:required - -finally:required - } { - Execute CODE, then execute cleanup code FINALLY. - If CODE completes normally, its value is returned after - executing FINALLY. - If CODE exits non-locally (as with error or return), FINALLY - is executed anyway. - - @option code Code to be executed that could throw and error - @option finally Cleanup code to be executed even if an error occurs - } { - global errorInfo errorCode - - # Execute CODE. - set return_code [catch {uplevel $code} string] - set s_errorInfo $errorInfo - set s_errorCode $errorCode - - # As promised, always execute FINALLY. If FINALLY throws an - # error, Tcl will propagate it the usual way. If FINALLY contains - # stuff like break or continue, the result is undefined. - uplevel $finally - - switch $return_code { - 0 { - # CODE executed without a non-local exit -- return what it - # evaluated to. - return $string - } - 1 { - # Error - return -code error -errorinfo $s_errorInfo -errorcode $s_errorCode $string - } - 2 { - # Return from the caller. - return -code return $string - } - 3 { - # break - return -code break - } - 4 { - # continue - return -code continue - } - default { - return -code $return_code $string - } - } - } - - #--------------------------------------- - ad_proc -public get_package_id {} { - @returns package_id of this package - } { - return [apm_package_id_from_key acs-mail-lite] - } #--------------------------------------- - ad_proc -public get_parameter { - -name:required - {-default ""} - } { - Returns an apm-parameter value of this package - @option name parameter name - @option default default parameter value - @returns apm-parameter value of this package - } { - return [parameter::get -package_id [get_package_id] -parameter $name -default $default] - } - - #--------------------------------------- ad_proc -public parse_email_address { -email:required } { Index: openacs-4/packages/acs-mail-lite/tcl/bounce-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail-lite/tcl/Attic/bounce-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-mail-lite/tcl/bounce-procs.tcl 9 Apr 2007 06:18:17 -0000 1.3 +++ openacs-4/packages/acs-mail-lite/tcl/bounce-procs.tcl 29 Aug 2007 12:59:34 -0000 1.4 @@ -17,14 +17,14 @@ ad_proc -private bounce_sendmail {} { @returns path to the sendmail executable } { - return [get_parameter -name "SendmailBin"] + return [parameter::get_from_package_key -package_key "acs-mail-lite" -parameter "SendmailBin"] } #--------------------------------------- ad_proc -private bounce_prefix {} { @returns bounce prefix for x-envelope-from } { - return [get_parameter -name "EnvelopePrefix"] + return [parameter::get_from_package_key -package_key "acs-mail-lite" -parameter "EnvelopePrefix"] } #--------------------------------------- @@ -105,11 +105,11 @@ Daily proc that sends out warning mail that emails are bouncing and disables emails if necessary } { - set max_bounce_count [get_parameter -name MaxBounceCount -default 10] - set max_days_to_bounce [get_parameter -name MaxDaysToBounce -default 3] - set notification_interval [get_parameter -name NotificationInterval -default 7] - set max_notification_count [get_parameter -name MaxNotificationCount -default 4] - set notification_sender [get_parameter -name NotificationSender -default "reminder@[address_domain]"] + set max_bounce_count [parameter::get_from_package_key -package_key "acs-mail-lite" -name MaxBounceCount -default 10] + set max_days_to_bounce [parameter::get_from_package_key -package_key "acs-mail-lite" -name MaxDaysToBounce -default 3] + set notification_interval [parameter::get_from_package_key -package_key "acs-mail-lite" -name NotificationInterval -default 7] + set max_notification_count [parameter::get_from_package_key -package_key "acs-mail-lite" -name MaxNotificationCount -default 4] + set notification_sender [parameter::get_from_package_key -package_key "acs-mail-lite" -name NotificationSender -default "reminder@[address_domain]"] # delete all bounce-log-entries for users who received last email # X days ago without any bouncing (parameter) Index: openacs-4/packages/acs-mail-lite/tcl/complex-send-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail-lite/tcl/Attic/complex-send-procs.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/acs-mail-lite/tcl/complex-send-procs.tcl 10 Jan 2007 21:22:05 -0000 1.7 +++ openacs-4/packages/acs-mail-lite/tcl/complex-send-procs.tcl 29 Aug 2007 12:59:34 -0000 1.8 @@ -248,28 +248,6 @@ set sender_addr $from_addr } - # Get the SMTP Parameters - set smtp [parameter::get -parameter "SMTPHost" \ - -package_id $mail_package_id -default [ns_config ns/parameters mailhost]] - if {$smtp eq ""} { - set smtp localhost - } - - set timeout [parameter::get -parameter "SMTPTimeout" \ - -package_id $mail_package_id -default [ns_config ns/parameters smtptimeout]] - if {$timeout eq ""} { - set timeout 60 - } - - set smtpport [parameter::get -parameter "SMTPPort" \ - -package_id [apm_package_id_from_key "acs-mail-lite"] -default 25] - - set smtpuser [parameter::get -parameter "SMTPUser" \ - -package_id [apm_package_id_from_key "acs-mail-lite"]] - - set smtppassword [parameter::get -parameter "SMTPPassword" \ - -package_id [apm_package_id_from_key "acs-mail-lite"]] - # default values for alternative_part_p # TRUE on mime_type text/html # FALSE on mime_type text/plain @@ -550,16 +528,10 @@ lappend bcc_list "\"[party::name -party_id $party]\" <[party::email_not_cached -party_id $party]>" } - smtp::sendmessage $multi_token \ - -header [list From "$from_string"] \ - -header [list Reply-To "$reply_to_string"] \ - -header [list To "[join $to_list ","]"] \ - -header [list CC "[join $cc_list ","]"] \ - -header [list BCC "[join $bcc_list ","]"] \ - -servers $smtp \ - -ports $smtpport \ - -username $smtpuser \ - -password $smtppassword + + acs_mail_lite::complex_smtp -multi_token $multi_token \ + -headers [list [list From "$from_string"] [list Reply-To "$reply_to_string"] \ + [list To "[join $to_list ","]"] [list CC "[join $cc_list ","]"]] #Close all mime tokens mime::finalize $multi_token -subordinates all @@ -597,14 +569,8 @@ foreach email $recipient_list { set message_id [mime::uniqueID] - smtp::sendmessage $multi_token \ - -header [list From "$from_string"] \ - -header [list Reply-To "$reply_to_string"] \ - -header [list To "$email"] \ - -servers $smtp \ - -ports $smtpport \ - -username $smtpuser \ - -password $smtppassword + acs_mail_lite::complex_smtp -multi_token $multi_token \ + -headers [list [list From "$from_string"] [list Reply-To "$reply_to_string"] [list To "$email"]] if { !$no_callback_p } { callback acs_mail_lite::complex_send \ @@ -626,14 +592,8 @@ set message_id [mime::uniqueID] set email "\"[party::name -party_id $party]\" <[party::email_not_cached -party_id $party]>" - smtp::sendmessage $multi_token \ - -header [list From "$from_string"] \ - -header [list Reply-To "$reply_to_string"] \ - -header [list To "$email"] \ - -servers $smtp \ - -ports $smtpport \ - -username $smtpuser \ - -password $smtppassword + acs_mail_lite::complex_smtp -multi_token $multi_token \ + -headers [list [list From "$from_string"] [list Reply-To "$reply_to_string"] [list To "$email"]] if { !$no_callback_p } { callback acs_mail_lite::complex_send \ @@ -718,5 +678,46 @@ } -finally { nsv_incr acs_mail_lite complex_send_mails_p -1 } - } + } + + ad_proc -private complex_smtp { + -multi_token:required + -headers:required + } { + Send messages via SMTP + + @param multi_token Multi Token generated which is passed directly to smtp::sendmessage + @param headers List of list of header key-value pairs like {{from malte@cognovis.de} {to malte@cognovis.de}} + } { + # Get the SMTP Parameters + set smtp [parameter::get -parameter "SMTPHost" \ + -package_id $mail_package_id -default [ns_config ns/parameters mailhost]] + if {$smtp eq ""} { + set smtp localhost + } + + set timeout [parameter::get -parameter "SMTPTimeout" \ + -package_id $mail_package_id -default [ns_config ns/parameters smtptimeout]] + if {$timeout eq ""} { + set timeout 60 + } + + set smtpport [parameter::get -parameter "SMTPPort" \ + -package_id [apm_package_id_from_key "acs-mail-lite"] -default 25] + + set smtpuser [parameter::get -parameter "SMTPUser" \ + -package_id [apm_package_id_from_key "acs-mail-lite"]] + + set smtppassword [parameter::get -parameter "SMTPPassword" \ + -package_id [apm_package_id_from_key "acs-mail-lite"]] + + set cmd_string "smtp::sendmessage $multi_token" + foreach header $headers { + append cmd_string "-header $header" + } + append cmd_string "-servers $smtp -ports $smtpport -username $smtpuser -password $smtppassword" + ds_comment $cmd_string + eval $cmd_string + + } } Index: openacs-4/packages/acs-mail-lite/tcl/incoming-mail-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail-lite/tcl/Attic/incoming-mail-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-mail-lite/tcl/incoming-mail-procs.tcl 9 Apr 2007 06:36:22 -0000 1.3 +++ openacs-4/packages/acs-mail-lite/tcl/incoming-mail-procs.tcl 29 Aug 2007 12:59:34 -0000 1.4 @@ -17,7 +17,7 @@ ad_proc -public address_domain {} { @returns domain address to which bounces are directed to } { - set domain [get_parameter -name "BounceDomain"] + set domain [parameter::get_from_package_key -package_key "acs-mail-lite" -parameter "BounceDomain"] if { $domain eq "" } { regsub {http://} [ns_config ns/server/[ns_info server]/module/nssock hostname] {} domain } @@ -91,6 +91,7 @@ if {!$callback_executed_p} { # Special treatment for e-mails which look like they contain an object_id set pot_object_id [lindex [split $email(to) "@"] 0] + ns_log Debug "Object_id for mail:: $pot_object_id" if {[ad_var_type_check_number_p $pot_object_id]} { if {[acs_object::object_p -id $pot_object_id]} { callback acs_mail_lite::incoming_object_email -array email -object_id $pot_object_id