Index: openacs-4/packages/contacts/lib/email.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/email.tcl,v diff -u -r1.32 -r1.33 --- openacs-4/packages/contacts/lib/email.tcl 2 Feb 2007 11:24:57 -0000 1.32 +++ openacs-4/packages/contacts/lib/email.tcl 6 Feb 2007 11:32:56 -0000 1.33 @@ -279,53 +279,46 @@ } } - set locale [lang::system::site_wide_locale] - - ad_returnredirect $return_url # Send the mail to all parties. + ns_log Notice "Recipients: $to" foreach party_id $to { - # Differentiate between person and organization if {[person::person_p -party_id $party_id]} { - contact::employee::get -employee_id $party_id -array employee - set first_names $employee(first_names) - set last_name $employee(last_name) - set name [string trim "$employee(person_title) $first_names $last_name"] - set salutation $employee(salutation) - set directphone $employee(directphoneno) - set mailing_address $employee(mailing_address) - set locale $employee(locale) + set salutation [contact::salutation -party_id $party_id] + db_1row names "select first_names, last_name from persons where person_id = :party_id" + set name "$first_names $last_name" } else { set name [contact::name -party_id $party_id] set salutation "Dear ladies and gentlemen" - set locale [lang::user::site_wide_locale -user_id $party_id] # the following is a hot fix (nfl 2006/10/20) set first_names "" set last_name "" - set mailing_address "" - set directphone "" } + set date [lc_time_fmt [dt_sysdate] "%q"] set values [list] - foreach element [list first_names last_name name date salutation mailing_address directphone] { + foreach element [list first_names last_name salutation] { lappend values [list "{$element}" [set $element]] } set subject [contact::message::interpolate -text $subject -values $values] + set content_body [contact::message::interpolate -text $content_body -values $values] # If we are doing mail through for tracking purposes # Set the reply_to_addr accordingly if {$mail_through_p} { - regsub -all {@} $from_addr {\#} reply_to + regsub -all {@} $from_addr {#} reply_to set reply_to_addr "${reply_to}@[acs_mail_lite::address_domain]" } else { set reply_to_addr $from_addr } + ns_log Notice "Recipients: $party_id" + acs_mail_lite::complex_send \ -to_party_ids $party_id \ -cc_addr $cc_list \ @@ -378,6 +371,7 @@ -single_email } + ad_returnredirect $return_url # Prepare the user message foreach cc_addr [concat $cc_list $bcc_list] { Index: openacs-4/packages/contacts/tcl/contacts-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contacts-callback-procs.tcl,v diff -u -r1.57 -r1.58 --- openacs-4/packages/contacts/tcl/contacts-callback-procs.tcl 2 Feb 2007 11:24:57 -0000 1.57 +++ openacs-4/packages/contacts/tcl/contacts-callback-procs.tcl 6 Feb 2007 11:32:56 -0000 1.58 @@ -1278,24 +1278,29 @@ set pot_email [lindex [split $email(to) "@"] 0] if {[string last "#" $pot_email] > -1} { # A match was found, now just forward the email - regsub -all {\#} $pot_email {@} to_addr + regsub -all {#} $pot_email {@} to_addr set from_addr [lindex $email(from) 0] - regsub -all {@} $from_addr {\#} reply_to + regsub -all {@} $from_addr {#} reply_to set reply_to_addr "${reply_to}@[acs_mail_lite::address_domain]" # make the bodies an array template::util::list_of_lists_to_array $email(bodies) email_body if {[exists_and_not_null email_body(text/html)]} { set body $email_body(text/html) + set mime_type "text/html" } else { set body $email_body(text/plain) + set mime_type "text/plain" } # Deal with the files set files "" set file_ids "" set import_p 1 + # As this is a connection less callback, set the IP Address to local + set peeraddr "127.0.0.1" + foreach file $email(files) { set file_title [lindex $file 2] set mime_type [lindex $file 0] @@ -1307,16 +1312,33 @@ # Shall we import the file into the content repository ? set sender_id [party::get_by_email -email $from_addr] + set package_id [acs_object::package_id -object_id $sender_id] if {$import_p && $sender_id ne ""} { - set revision_id [cr_import_content \ - -title $file_title \ - -description "File send by e-mail from $email(from) on subject $email(subject)" \ - $sender_id \ - $file_path \ - [file size $file_path] \ - $mime_type \ - "[clock seconds]-[expr round([ns_rand]*100000)]"] + set existing_item_id [content::item::get_id_by_name -name $file_title -parent_id $sender_id] + if {$existing_item_id ne ""} { + set item_id $existing_item_id + } else { + set item_id [db_nextval "acs_object_id_seq"] + content::item::new -name $file_title \ + -parent_id $sender_id \ + -item_id $item_id \ + -package_id $package_id \ + -creation_ip 127.0.0.1 \ + -creation_user $sender_id \ + -title $file_title + } + set revision_id [content::revision::new \ + -item_id $item_id \ + -tmp_filename $file_path\ + -creation_user $sender_id \ + -creation_ip 127.0.0.1 \ + -package_id $package_id \ + -title $file_title \ + -description "File send by e-mail from $email(from) to $email(to) on subject $email(subject)" \ + -mime_type $mime_type] + + file delete $file_path lappend file_ids $revision_id } else { lappend files [list $file_title $mime_type $file_path] @@ -1348,6 +1370,7 @@ -to_addr $to_addr \ -subject $subject \ -body $body \ + -mime_type $mime_type \ -single_email \ -files $files \ -file_ids $file_ids \