Index: openacs-4/packages/acs-mail-lite/lib/email.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail-lite/lib/Attic/email.tcl,v diff -u -r1.19 -r1.20 --- openacs-4/packages/acs-mail-lite/lib/email.tcl 12 Mar 2006 14:33:21 -0000 1.19 +++ openacs-4/packages/acs-mail-lite/lib/email.tcl 17 Mar 2006 10:06:11 -0000 1.20 @@ -60,7 +60,7 @@ no_callback_p:text(hidden) title:text(hidden),optional {message_type:text(hidden) {value "email"}} - {to:text(checkbox),multiple + {to:text(checkbox),multiple,optional {label "[_ acs-mail-lite.Recipients]"} {options $recipients } {html {checked 1}} @@ -88,15 +88,15 @@ } if {$checked_p == "t"} { append form_elements { - {to:text(checkbox),multiple + {to:text(checkbox),multiple,optional {label "[_ acs-mail-lite.Recipients]"} {options $recipients } {html {checked 1}} } } } else { append form_elements { - {to:text(checkbox),multiple + {to:text(checkbox),multiple,optional {label "[_ acs-mail-lite.Recipients]"} {options $recipients } } @@ -210,7 +210,9 @@ # Remove all spaces in cc regsub -all " " $cc "" cc - set cc_list [split $cc ";"] + # Just in case someone is using "," instead of ";" + regsub -all ";" $cc "," cc + set cc_list [split $cc ","] template::multirow create messages message_type to_addr to_party_id subject content_body @@ -267,19 +269,38 @@ foreach element [list first_names last_name name date] { lappend values [list "{$element}" [set $element]] } - template::multirow append messages $message_type $to_addr $party_id [acs_mail_lite::message_interpolate -text $subject -values $values] [acs_mail_lite::message_interpolate -text $content_body -values $values] + # Append the CC for each to recipient + template::multirow append messages $message_type $to_addr $party_id [acs_mail_lite::message_interpolate -text $subject -values $values] [acs_mail_lite::message_interpolate -text $content_body -values $values] $cc + # Link the file to all parties if {[exists_and_not_null revision_id]} { application_data_link::new -this_object_id $revision_id -target_object_id $party_id } } - + # Send the email to all CC in cc_list foreach email_addr $cc_list { - set name $email_addr - set first_names [split $email_addr "@"] - set last_name $first_names + set party_id [party::get_by_email -email $email_addr] + + # The CC E-Mail is unknown in the system. Create the person. + if {[string eq "" $party_id]} { + if {[regexp {(.+)[\.|_](.+)@(.+)} $email_addr match first_names last_name url]} { + set name "$first_names $last_name" + } else { + set name $email_addr + set first_names "." + set last_name [lindex [split $email_addr "@"] 0] + } + if {$contacts_p} { + set party_id [contacts::person::new -email $email_addr -first_names $first_names -last_name $last_name] + ns_log Notice "Contact generated for $first_names $last_name at $email_addr" + } else { + set party_id [person::new -email $email_addr -first_names $first_names -last_name $last_name] + ns_log Notice "Person generated for $first_names $last_name at $email_addr" + } + } + set date [lc_time_fmt [dt_sysdate] "%q"] set to $name set to_addr $email_addr @@ -288,6 +309,7 @@ foreach element [list first_names last_name name date] { lappend values [list "{$element}" [set $element]] } + if {$contacts_p} { set party_revision_id [contact::live_revision -party_id $party_id] set locale [lang::user::site_wide_locale -user_id $party_id] @@ -296,11 +318,10 @@ lappend value [list "{salutation}" $salutation] } } - template::multirow append messages $message_type $to_addr "" [acs_mail_lite::message_interpolate -text $subject -values $values] [acs_mail_lite::message_interpolate -text $content_body -values $values] + template::multirow append messages $message_type $to_addr $party_id [acs_mail_lite::message_interpolate -text $subject -values $values] [acs_mail_lite::message_interpolate -text $content_body -values $values] "" } - set to_list [list] template::multirow foreach messages { Index: openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-callback-procs.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-callback-procs.tcl 30 Oct 2005 11:53:15 -0000 1.7 +++ openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-callback-procs.tcl 17 Mar 2006 10:06:11 -0000 1.8 @@ -19,6 +19,7 @@ {-subject} {-object_id} {-file_ids} + {-cc} } { Callback for executing code after an email has been send using the complex send mechanism. 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.40 -r1.41 --- openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl 12 Mar 2006 14:33:22 -0000 1.40 +++ openacs-4/packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl 17 Mar 2006 10:06:11 -0000 1.41 @@ -729,6 +729,7 @@ -sendlist:required -msg:required {-valid_email_p 0} + {-cc ""} -message_id:required -package_id:required } { @@ -762,7 +763,7 @@ if {[catch { set err1 {} set f [open "|$sendmail" "w"] - puts $f "From: $from_addr\nTo: $pretty_to\n$msg" + puts $f "From: $from_addr\nTo: $pretty_to\nCC: $cc\n$msg" set err1 [close $f] } err2]} { ns_log Error "Attempt to send From: $from_addr\nTo: $pretty_to\n$msg failed.\nError $err1 : $err2" @@ -1010,6 +1011,7 @@ {-folder_id ""} {-mime_type "text/plain"} {-object_id ""} + {-cc ""} -no_callback:boolean -use_sender:boolean } { @@ -1120,7 +1122,7 @@ set eh [util_list_to_ns_set $extraheaders] ns_sendmail $to_address $from_addr $subject $body $eh $bcc } else { - acs_mail_lite::sendmail -from_addr $sender_addr -sendlist [get_address_array -addresses $to_addr] -msg $packaged -valid_email_p t -message_id $message_id -package_id $package_id + acs_mail_lite::sendmail -from_addr $sender_addr -sendlist [get_address_array -addresses $to_addr] -msg $packaged -valid_email_p t -message_id $message_id -package_id $package_id -cc $cc } if {[empty_string_p $package_id]} { @@ -1134,6 +1136,7 @@ -to_party_id [party::get_by_email -email $to_addr] \ -body $body \ -message_id $message_id \ + -cc $cc \ -subject $subject \ -object_id $object_id \ -file_ids $file_ids