acs_mail_lite::bounce_ministry (private)

 acs_mail_lite::bounce_ministry -header_array_name header_array_name

Defined in packages/acs-mail-lite/tcl/email-inbound-procs.tcl

Check if this email is notifying original email bounced. If is a bounced notification, process it. Returns 1 if bounced or an auto generated reply that should be ignored, otherwise returns 0 Expects header_array to have been previously processed by these procs:

Switches:
-header_array_name
(required)
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 acs_mail_lite::inbound_queue_pull acs_mail_lite::inbound_queue_pull (private) acs_mail_lite::bounce_ministry acs_mail_lite::bounce_ministry acs_mail_lite::inbound_queue_pull->acs_mail_lite::bounce_ministry acs_mail_lite::bouncing_user_p acs_mail_lite::bouncing_user_p (private) acs_mail_lite::bounce_ministry->acs_mail_lite::bouncing_user_p db_dml db_dml (public) acs_mail_lite::bounce_ministry->db_dml db_resultrows db_resultrows (public) acs_mail_lite::bounce_ministry->db_resultrows party::get_by_email party::get_by_email (public) acs_mail_lite::bounce_ministry->party::get_by_email

Testcases:
No testcase defined.
Source code:
    upvar 1 $header_array_name h_arr
    # This is called ministry, because it is expected to grow in complexity
    # as bounce policy becomes more mature.

    # The traditional OpenACS MailDir way:
    # code in acs_mail_lite::load_mails
    # in which, if there is a bounce, calls:
    # acs_mail_lite::record_bounce
    # and later batches some admin via
    # acs_mail_lite::check_bounces
    # This approach likely does not work for
    # standard email accounts where a FixedSenderEmail is expected and
    # a dynamic (unstatic) email
    # would bounce back again and therefore never be reported in system.

    # Specifics of the old way:
    # acs_mail_lite::record_bounce which calls:
    # acs_mail_lite::bouncing_user_p -user_id $h_arr(aml_user_id)

    # bounces are checked from the inbound queue
    # before checking other cases that may trigger callbacks


    set aml_list [list  aml_package_id  aml_party_id  aml_object_id  aml_other  aml_type  aml_to_addrs  aml_from_addrs  aml_datetime_cs ]
    foreach idx $aml_list {
        if { ![info exists h_arr(${idx})] } {
            set h_arr(aml_package_id) ""
        }
    }

    set ignore_p 0
    if { $h_arr(aml_type) ne "" && $h_arr(aml_type) ne "in_reply_to" } {
        set ignore_p 1
        # Record bounced email?
        set party_id_from_addrs [party::get_by_email  -email $h_arr(aml_from_addrs)]

        if { $party_id_from_addrs ne "" } {
            set user_id $party_id_from_addrs
            if { ![acs_mail_lite::bouncing_user_p -user_id $user_id ] } {

                # Following literally from acs_mail_lite::record_bounce
                ns_log Debug "acs_mail_lite::bounce_ministry.2264  Bouncing email from user '${user_id}'"
                # record the bounce in the database
                db_dml record_bounce {}
                if { ![db_resultrows]} {
                    db_dml insert_bounce {}
                }
                # end code from acs_mail_lite::record_bounce

                if { $h_arr(aml_party_id) ne $user_id
                     || $h_arr(aml_datetime_cs) eq ""
                 } {
                    # Log it, because it might be a false positive.
                    # Existence of aml_datetime_cs means unique_id was signed.
                    # See acs_mail_lite::unique_id_parse
                    ns_log Warning "acs_mail_lite::bounce_ministry.2275  Bounced email apparently from user_id '${user_id}'  with headers: '[array get h_arr]'"

                }
            }

        } else {
            # This is probably a bounce, but not from a recognized party
            # Log it, because it might help with email related issues.
            ns_log Warning "acs_mail_lite::bounce_ministry.2287  email_type '$h_arr(aml_type)' ignored. headers: '[array get h_arr]'"

        }
    }


    return $ignore_p
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
packages/acs-mail-lite/tcl/email-inbound-procs.xql

[ hide source ] | [ make this the default ]
Show another procedure: