Forum OpenACS Development: How to Personalize bulk_mail

Collapse
Posted by MaineBob OConnor on
We are using bulk_mail to send mail to our users like this:
if { $submitaction == "Broadcast" } {
   # broadcast this message
  util_user_message -replace -html -message "Your broadcast has been queued."

  bulk_mail::new -package_id $package_id \
       -from_addr $from_email \
       -subject $subject \
       -message $body \
       -message_type "text" \
       -query $query
} else {

We would like to personalize the message body:

Hello {first_names} {last_name},

Is there a way in this proc or perhaps another package that can accomplish adding variables like first_names, last_name and other user variables?

Collapse
Posted by Dave Bauer on
The API documentation for bulk_mail::new explains how it works:

You select all the columns you need in the SQL query passed into the query parameter. The column names will be available as variables for replacement in the message body.

-query (required)
    a query that must select the email address to send to as 'email' and can select any other values that will be interpolated into the subject and message of the bulk_mail for each recipient. if column 'foo' is selected it's value will be interpolated anywhere that '{foo}' appears in the subject or message of the bulk_mail. if columns 'from_addr', 'reply_to', 'subject', or 'message' are selected, their respective values will also become the 'from_addr', 'reply_to', 'subject', and 'message' on a per recipient basis.
Collapse
Posted by Matthew Geddert on
Contacts can do this type of mail merge and more... but its not officially released (even though at least 7 business/school sites are using it in production as a CRM with up to 40,000 contacts not individuals playing around). You need to use the latests ams and contacts packages from HEAD to get it running...