Forum OpenACS Development: Re: RFC: New OpenACS Mail Procedures

Collapse
Posted by Tilmann Singer on
Specifying email addresses

We need a good flexible solution to pass email addresses in procedure parameters. It should deal with user_id's, single email addresses ('fritz@fritz.com') and pretty addresses ('Fritz Fitzke <fritz@fritz.com>'), possibly not burdening the caller with the assembly of the pretty string. Some parameters allow for single addresses only (e.g. From:), others for multiple addresses (e.g. Cc:).

What about liberally accepting a list and interpreting it so that all the following calls were legal:

mek::send -to 12345
mek::send -to {12345 12346 132457}
mek::send -to fritz@fritz.com
mek::send -to {"Fritz Fitzke" <fritz@fritz.com>}
mek::send -to {{"Fritz Fitzke" <fritz@fritz.com>} {"Test User" <test@user.com>}}
The way to correctly distinguish the last two forms would be a bit kludgy but it would work somehow, and this method would at least save us from having to define several variants per parameter such as -to, -to_pretty etc.

The generation of the pretty form could be done by a utility proc, e.g.

mek::build_address -email fritz@fritz.com -pretty_name "Fritz Fitzke"
would return {"Fritz Fitzke" <fritz@fritz.com>}

So that the last from the examples above could be also written like that:

mek::send -to [list \
  [mek::build_address -pretty_name "Fritz Fitzke" -email "fritz@fritz.com"] \
  [mek::build_address -pretty_name "Test User" -email "test@user.com"] \
 ]