acs_mail_lite::load_mails (public, deprecated)

 acs_mail_lite::load_mails -queue_dir queue_dir

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

Deprecated. Invoking this procedure generates a warning.

Scans for incoming email. The function requires incoming emails that comply to the following syntax rule:

        [<SitePrefix>][-]<ReplyPrefix>-Whatever@<BounceDomain>

        [] = optional
        <> = Package Parameters
        
If no SitePrefix is set we assume that there is only one OpenACS installation. Otherwise only messages are dealt with which contain a SitePrefix. ReplyPrefixes are provided by packages that implement the callback acs_mail_lite::incoming_email and provide a package parameter called ReplyPrefix. Only implementations are considered where the implementation name is equal to the package key of the package. Also we only deal with messages that contain a valid and registered ReplyPrefix. These prefixes are automatically set in the acs_mail_lite_prefixes table.

Switches:
-queue_dir (required)
Options:
-queue_dir
The location of the qmail mail (BounceMailDir) queue in the file-system i.e. /home/service0/mail.
Author:
Nima Mazloumi <nima.mazloumi@gmx.de>
Created:
2005-07-15

See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 acs_mail_lite::scan_replies acs_mail_lite::scan_replies (public, deprecated) acs_mail_lite::load_mails acs_mail_lite::load_mails acs_mail_lite::scan_replies->acs_mail_lite::load_mails

Testcases:
No testcase defined.
Source code:
ns_log Notice "Deprecated proc acs_mail_lite::load_mails used:\n[ad_get_tcl_call_stack]"


        # get list of all incoming mail
        if {[catch {
            set messages [glob "$queue_dir/new/*"]
        } errmsg]} {
            if {[string match "no files matched glob pattern*"  $errmsg ]} {
                ns_log Debug "load_mails: queue dir = $queue_dir/new/*, no messages"
            } else {
                ns_log Error "load_mails: queue dir = $queue_dir/new/ error $errmsg"
            }
            return [list]
        }

        # loop over every incoming mail
        foreach msg $messages {
            ns_log Debug "load_mails: opening $msg"
            array set email {}

            # This will parse the E-mail and extract the files to the filesystem
            parse_email -file $msg -array email

            set email(to) [parse_email_address -email $email(to)]
            set email(from) [parse_email_address -email $email(from)]
            set subject [lindex $email(subject) 0]
            if {$email(bodies) eq ""} {
                ad_script_abort
                ns_log Notice "E-Mail without body"
            }

            # Do no execute any callbacks if the email is an autoreply.
            # Thanks to Vinod for the idea and the code
            set callback_executed_p [acs_mail_lite::autoreply_p  -subject $subject  -from $email(from)]

            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 {[string is integer -strict  $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

                        # Mark that the callback has been executed already
                        set no_callback_p 1
                    }
                }
            }

            if {!$callback_executed_p} {
                # We execute all callbacks now
                callback acs_mail_lite::incoming_email -array email
            }

            #let's delete the file now
            if {[catch {file delete -- $msg} errmsg]} {
                ns_log Error "load_mails: unable to delete queued message $msg: $errmsg"
            } else {
                ns_log Debug "load_mails: deleted $msg"
            }
        }
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
packages/acs-mail-lite/tcl/legacy-inbound-procs.xql

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