I've set up a vacation message system where users set/unset their
vacation autoreply message by sending a message with a particular
subject to themselves. The message is stored in an SQL database.

The problem I am having is that newlines are not being preserved, so I I
send a multi-line vacation message, it gets inserted into the database
as one big line. What sort of escaping must I do in order to get this
right?

This is what I'm doing:

#---------------------
# Vacation
#---------------------

SQL_TURN_VACATION_ON = ${lookup mysql{INSERT INTO account_option 
(account_option.account_id, account_option.name, account_option.value) 
VALUES(SQL_USER_ID, 'vacation_message', 
'${quote_mysql:${escape:$message_body}}')}{1}{0}}

SQL_TURN_VACATION_OFF = ${lookup mysql{DELETE FROM account_option WHERE 
account_option.account_id = 'SQL_USER_ID' AND account_option.name = 
'vacation_message'}{1}{0}}

SQL_VACATION_IS_ON = ${lookup mysql{SELECT account_option.value FROM 
account_option INNER JOIN account ON account_option.account_id = account.id 
INNER JOIN domain ON account.domain_id = domain.id WHERE domain.name = 
'${domain}' AND account.username = '${local_part}' AND account_option.name = 
'vacation_message'}{1}{0}}

SQL_VACATION_MESSAGE = ${lookup mysql{SELECT account_option.value FROM 
account_option INNER JOIN account ON account_option.account_id = account.id 
INNER JOIN domain ON account.domain_id = domain.id WHERE domain.name = 
'${domain}' AND account.username = '${local_part}' AND account_option.name = 
'vacation_message'}{$value}fail}


## vacation routers

user_vacation_on:
     driver = accept
     condition = ${if and{ {eq{$local_part}{${local_part:$sender_address}}} 
{match{${lc:$h_subject:}}{\N^\s*vacation\s+on\N}}} {yes}{no}}
     transport = vacation_on

user_vacation_off:
     driver = accept
     condition = ${if and{ {eq{$local_part}{${local_part:$sender_address}}} 
{match{${lc:$h_subject:}}{\N^\s*vacation\s+off\N}}} {yes}{no}}
     transport = vacation_off

user_vacation:
     driver = accept
     # do not reply to errors, lists, or if no vacation message has been set
     condition = "${if and { {eq{SQL_VACATION_IS_ON}{1}} {!match 
{$h_precedence:}{(?i)junk|bulk|list}} {def:sender_address} }{yes}{no} }"
     no_expn
     # do not reply to errors and bounces or lists
     senders = " ! [EMAIL PROTECTED]:\
                 ! [EMAIL PROTECTED]:\
                 ! [EMAIL PROTECTED]:\
                 ! [EMAIL PROTECTED]:\
                 ! [EMAIL PROTECTED]
                 ! [EMAIL PROTECTED]"
     transport = vacation_reply
     unseen


## vacation transports

vacation_reply:
     driver = autoreply
     user = mail
     group = mail
     from = Autoreply System <[EMAIL PROTECTED]>
     log = /var/mail/${domain}/${local_part}/vacation.log
     once = /var/mail/${domain}/${local_part}/vacation.db
     once_repeat = 7d
     subject = ${if def:h_Subject: {Re: 
${quote:${escape:${length_50:$h_Subject:}}} (autoreply)} {I am on vacation} }
     text = SQL_VACATION_MESSAGE
     to = "${sender_address}"

vacation_on:
     driver = autoreply
     text = ${if eq{SQL_TURN_VACATION_ON}{1}{Your vacation message has been set 
to: \n\nSQL_VACATION_MESSAGE}{Unable to set vacation message. Please contact PC 
Support.}}
     from = Autoreply System <[EMAIL PROTECTED]>
     subject = Re: Vacation on
     to = ${sender_address}

vacation_off:
     driver = autoreply
     text = ${if eq{SQL_TURN_VACATION_OFF}{1}{Vacation message removed.}{Unable 
to remove vacation message. Please contact PC Support.}}
     from = Autoreply System <[EMAIL PROTECTED]>
     subject = Re: Vacation off
     to = ${sender_address}


-davidc

-- 
gpg-key: http://www.zettazebra.com/files/key.gpg

Attachment: signature.asc
Description: This is a digitally signed message part

-- 
## List details at http://www.exim.org/mailman/listinfo/exim-users 
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://www.exim.org/eximwiki/

Reply via email to