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:


        [] = 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.

-queue_dir (required)
The location of the qmail mail (BounceMailDir) queue in the file-system i.e. /home/service0/mail.
Nima Mazloumi <>

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

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 ""} {
                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:

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