Under the Hood - Email Parsing

EZSurvey can read email messages in many formats. Here's a brief description of the parsing algorithm:

Verbose human-readable messages

When you send a form as email. EZSurvey scans the first 50 characters of each line of text until it recognizes the beginning of a question. Then, it scans for brackets to indicate responses.

1. For write-in questions, the following lines of text until the next question will be included in the response. You may (and this is the default for short questions) enclose the response in brackets. i.e.

1. What is your address?
[332 Seneca Dr ]
[Seattle WA 98551 ]

1. What is your address? [322 Seneca Dr ]

If the answer is to be on the same line as the question, it must be enclosed in brackets.

2. For multiple choice questions, any non-white space characters inside the brackets will be interpreted as a response.

3. If a multiple-choice question has only one available response (as in Yes), the response text does not have to be printed. Any mark inside the brackets is equivalent to answering yes.

4. Multiple choice responses can go on the separate lines, so long as they are contiguous.

5. Write-in question responses can go on the same line as the question. They don't have to come on the next line.

Terse Human-readable Messages

You can send abbreviated forms. Note that capitalization of the fieldnames and of the question text does not matter, but capitalization of the responses does.

1. A pair of brackets can appear with the response on the same line as the fieldname.

2. If a pair of brackets appear next to the question text, you can type in a response code (capitalization matters!) for the question in the brackets.

3. If a multiple choice question only has one answer, any mark in the brackets next to the fieldname will indicate a response.

4. To select more than one response, use commas to separate response codes.

5. Write-in questions should have the brackets to the left when only the fieldname is presented, or the brackets on the right when the whole question is written out.

CGI-email Messages

EZSurvey can parse email messages generated by web servers. They should possess this form:

1. The DATABASE field is required to identify the project to which the response belongs. The data values must be URL decoded.

2. If the same field appears on adjacent lines, the responses will be added together.

3. Multiple response questions can be sent as

FIELDNAME_CODE=1
FIELDNAME=1,2,3

4. Capitalization matters for codes, but not for fieldnames.

Email Reading

When EZSurvey reads email messages, it saves the message text to numbered files of the form 1.txt, 2.txt, etc... It also appends some information to the file in the same format as message headers:

X-SENDER: sender name, stored in the HOST field of your database
X-DATE: date the message was sent
X-TIME: time the message was sent