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.108.2.32 -r1.108.2.33 --- openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl 16 Jul 2024 17:11:03 -0000 1.108.2.32 +++ openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl 17 Jul 2024 13:53:51 -0000 1.108.2.33 @@ -210,7 +210,7 @@ ns_log notice "SMTP call <$cmd>" ns_log Debug "send cmd: $cmd" - if {[catch $cmd errorMsg]} { + if {[catch $cmd errorMsg]} { ns_log Error "acs-mail-lite::smtp: error $errorMsg while executing\n$cmd" error $errorMsg } @@ -1021,6 +1021,35 @@ } return $domain } + + ad_proc configured_p {} { + + Determine, whether the outgoing SMTPHost is configured and + reachable. + + } { + # + # We have currently no good way to check, whether the outgoing + # email server is fully configured and accepts our + # emails. Here we check only, whether we can connect to the + # configured server. + # + set success 0 + set params [get_delivery_parameters] + + try { + lassign [ns_sockopen -timeout 100ms [dict get $params SMTPHost] [dict get $params SMTPPort]] rid wid + set readCheck [ns_sockcheck $rid] + set writeCheck [ns_sockcheck $wid] + set success [expr {$readCheck && $writeCheck}] + } on error {errorMsg} { + } finally { + catch {close $rid} + catch {close $wid} + } + + return $success + } } # Local variables: Index: openacs-4/packages/acs-mail-lite/tcl/test/acs-mail-lite-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail-lite/tcl/test/acs-mail-lite-procs.tcl,v diff -u -r1.1.2.2 -r1.1.2.3 --- openacs-4/packages/acs-mail-lite/tcl/test/acs-mail-lite-procs.tcl 16 Jul 2024 17:11:04 -0000 1.1.2.2 +++ openacs-4/packages/acs-mail-lite/tcl/test/acs-mail-lite-procs.tcl 17 Jul 2024 13:53:51 -0000 1.1.2.3 @@ -60,15 +60,10 @@ aa_section "Immediate sending" # - # We have currently no good way to check, whether the - # outgoing email server is configured properly. Therefore, - # we perform this test only, when the nssmptd module is - # loaded. In this case, we assume, it is configured. When - # mail is not configured, the test might fail in - # unpredictable ways, which are not necessarily related to - # the code. + # We can only test an immediate send operation, when the + # SMTP server is configured and available. # - if {[info commands ns_smtpd] ne ""} { + if {[::acs_mail_lite::configured_p]} { acs_mail_lite::send \ -to_addr $to_addr \ @@ -96,7 +91,7 @@ and party_id = :recipient_id }] } else { - aa_log "Test skipped, since 'ns_smtpd' is not configured" + aa_log "Test skipped, since the SMTP host is apparently not configured" } } -teardown_code {