Forum OpenACS Development: BehaveLikeOutlookP

Collapse
Posted by Malte Sussdorff on
I am facing the situation that a client of ours needs "Real" email sending, which means that you are sending *one* email to multiple "to", multiple "cc" and multiple "bcc" recipients. The goal is that the recipients are able to see who else recieved this e-mail.

Sadly acs-mail-lite sends out single emails for each of these recipients.

I played around a little bit with complex_send and managed to add a "cc" flag to it which correctly sends the emails in CC. I think I could go the same way with BCC.

Sadly though this does not work with multiple "to" recipients as both acs_mail_lite::sendmail and ::smtp are spliting the recipients array up and send out individual emails for each of them. Imagine the fun the "cc" guys had when I used 3 "to" recipients (they got three individual e-mails).

Which brings me to my questions:

a) Is sending separate E-Mails the behaviour people would expect when they call acs-mail-lite::send with multiple email recipients. After all you would like to send one e-mail to multiple recipients otherwise you would just call acs-mail-lite::send separately for every user.
b) as a change to "a)" requires a TIP I am inclined to add a parameter "BehaveIndividualMailsP", default to "1" which will send only one email with multiple "to" and "cc" and "bcc" if set to 0. The alternative would be to clone acs-mail-lite::complex_send and create a new procedure for this kind of e-mail sending.

Assuming I have the problem solved and I only send out "one" e-mail, the next challenge lies in the mail-tracking. Obviously you would like the e-mail to show up in each recipients mail-tracking view. So I had been thinking about getting rid of the recipient_id field and add a "recipients" "cc" and "bcc" field which contains the list of e-mail addresses the e-mail was send to. Furthermore I would create a mapping table for "log_id / recipient_id" where the recipient_id belongs to any of the "to" "cc" or "bcc" recipients used in the email.

So far, so good (... I hope, objections and critique more than welcome). But what do we do with e-mail addresses that are not in the system? How are we tracking them? At the moment I am adding a new person (as I can't add just a new party, though maybe I could change party::new to add me a party without an object_type), as I would like to search for the person in the contacts interface (okay, search for the e-mail). But is this a desired behaviour in general or should I turn this on/off using a parameter in mail-tracking? I would add the person into the "mail_tracking_recipients" group so you could quickly filter them out and probably do something useful with them (like enter the real first_names / last_name).

Does the last part make any sense or would you say "don't bother" and add an "email" field to mail-tracking mapping table, so that you could either search by party_id (if known) or email address (if unknown) and add the ability to filter by e-mail address to the mail-tracking include?

Collapse
2: Re: BehaveLikeOutlookP (response to 1)
Posted by Dave Bauer on
Malte,

Let's think of the best name for the switch.

We'll need 1) a parameter to acs-mail-lite to specify if ALL multiple recipient emails go out this way (if its possible)
2) A switch to acs_mail_list::send (or complex_send, I don't know the exact difference) to specify the exact behavior for any individual email that would override the paramter. I'd add this because an individual application, ie: bug-tracker or other workflow based system, might want to use the CC feature, but for forums, you might not. It gets pretty complicated quickly.

For the mail tracking I would add a "to_type" column that could be "to" "cc" or "bcc". That makes the most sense to me, then you can default to "to" and it works the same as it does now, but if extended to support the new feature.

As long as everything is optional and the default behavior is the same as exists now it should work.

Collapse
3: Re: BehaveLikeOutlookP (response to 1)
Posted by Carl Robert Blesius on
I noticed Malte added this code to acs-mail-lite after posting:

# 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" } }

Now we have contacts specific code in an essential package.
Can someone fill me in on the best way to prevent Malte's contacts code from creeping into acs-mail-lite?

Carl

P.S. Malte, why are you adding strangly named people to the system using person::new? Will this effect future registrations if someone has been "added" earlier through inclusion in an email exchange within the contacts package?

Collapse
4: Re: Re: BehaveLikeOutlookP (response to 3)
Posted by Malte Sussdorff on
Carl, wrong commit from testing, so don't worry, removed. As for your direct question:

A) Indeed person::new only makes sense if we use contacts in conjunction with mail-tracking.

B) Not an issue. Code has been written to take this into account (aka: e-mail address already exists in the system as a person but not as a user). But it is not committed as I just overwrote the registration process through a custom package. And this is an issue you face with *every* contacts installation, not only if there are arbitrary e-mails in the system. So we might want to start a new thread and discuss the best behaviour there.

Collapse
Posted by Carl Robert Blesius on
A) Giving end users the option of arbitrarily adding others to the database might make sense in applications that you are building for specific business clients, but I am having trouble fitting it into how I want to run my sites/applications so I am very happy to see you remove this code from core because there is a danger others will use it as an example. It is also a relief to hear it was test code, b/c it helps me rationalize why you were falling back on naming people using punctuation if no accurate data is available.

B) Happy to contribute to the discussion but I doubt I will be using contacts for any sites I run. It seems it has become a very "customer relationship management" specific package based on the demos you have given me and the discussion I have had with people about it.

Collapse
6: New complex send (response to 1)
Posted by Malte Sussdorff on
The acs_mail_lite::complex_send procedure is now able to deal with a couple of new flags:

- to_party_ids, cc_party_ids, bcc_party_ids: These are lists of IDs to whom we will send the email.

- to_group_ids, cc_group_ids, bcc_group_ids: Same as above, just that the group_id will be resolved for the list of recipients.

- to_addr, cc_addr, bcc_addr. These are useful if you are sending an email to a contact which does not have a party_id. No user creation or anything is happening. Mail tracking knows how to deal with that in a different way (see below).

All the above flags can be used at the same time in a mix and match fashion (send an e-mail TO a group, the sysadmin in BCC and an additional contact in CC).

- file_ids. Send the files (does not matter if this is a revision or an item_id, internally we process the item_ids using the latest revision) in the e-mail as an attachment.

- files. List of file_title, mime_type, file_path (as in full path to the file) combination of files to be attached. This allows you to include files generated by third party software on your harddisk.

- folder_ids. List of folders who's content to send as attachments. This does not go through the folder recursively.

- single_email(_p). Flag that indicates that only one mail will be send (in contrast to one e-mail per recipient). So if set, the e-mail will be send out in one single e-mail (with the to, cc and bcc fields filled out in the "First_Names Last_Name <email>" fashion). If not set, each recipient gets an individual email, regardless whether they are TO, CC or BCC.

This is on HEAD as it requires TCLLLIB to be installed.

Collapse
7: Re: New complex send (response to 6)
Posted by Malte Sussdorff on
Out of curiosity: As the group_ids are party_ids as well, should complex_send have a -to_group_ids switches in the first place, or should we put the logic to detect if a party_id is a group or not into complex_send.

This would be more logical with regards to the datamodel (after all groups are parties), though it might be a little bit confusing. What do you guys think?