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.19 -r1.20 --- openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl 15 Jun 2005 13:27:50 -0000 1.19 +++ openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl 15 Jun 2005 16:03:38 -0000 1.20 @@ -684,6 +684,9 @@ } { ## Extract "from" email address set from_addr [parse_email_address -email $from_addr] + + set from_party_id [party::get_by_email -email $from_addr] + set to_party_id [party::get_by_email -email $to_addr] ## Get address-array with email, name and user_id set to_addr [get_address_array -addresses [string map {\n "" \r ""} $to_addr]] @@ -733,6 +736,16 @@ # else, store it in the db and let the sweeper deliver the mail db_dml create_queue_entry {} } + + + callback acs_mail_lite::send \ + -package_id $package_id \ + -from_party_id $from_party_id \ + -to_party_id $to_party_id \ + -body $body \ + -message_id $message_id \ + -subject $subject + return $message_id } @@ -748,6 +761,7 @@ {-file_ids ""} {-folder_id ""} {-mime_type "text/plain"} + {-object_id ""} } { Prepare an email to be send with the option to pass in a list @@ -771,6 +785,8 @@ @param mime_type MIME Type of the mail to send out. Can be "text/plain", "text/html". + @param object_id The ID of the object that is responsible for sending the mail in the first place + } { @@ -782,10 +798,11 @@ set tokens [list $message_token] if {[exists_and_not_null folder_id]} { - db_foreach get_file_info "select r.mime_type,r.title, r.content as filename + db_foreach get_file_info "select r.revision_id,r.mime_type,r.title, r.content as filename from cr_revisions r, cr_items i where r.item_id = i.item_id and i.parent_id = :folder_id" { lappend tokens [mime::initialize -param [list name "[ad_quotehtml $title]"] -canonical $mime_type -file "[cr_fs_path]$filename"] + lappend file_ids $revision_id } } else { @@ -801,9 +818,23 @@ #Close all mime tokens mime::finalize $multi_token -subordinates all + set message_id [generate_message_id] - sendmail -from_addr $from_addr -sendlist [get_address_array -addresses $to_addr] -msg $packaged -valid_email_p t -message_id [generate_message_id] -package_id $package_id +# sendmail -from_addr $from_addr -sendlist [get_address_array -addresses $to_addr] -msg $packaged -valid_email_p t -message_id $message_id -package_id $package_id + + if {[empty_string_p $package_id]} { + set package_id [apm_package_id_from_key "acs-mail-lite"] + } + callback acs_mail_lite::complex_send \ + -package_id $package_id \ + -from_party_id [party::get_by_email -email $from_addr] \ + -to_party_id [party::get_by_email -email $to_addr] \ + -body $body \ + -message_id $message_id \ + -subject $subject \ + -object_id $object_id \ + -file_ids $file_ids } ad_proc -private sweeper {} {