Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
en:create:functions:mailresume [11.04.2018 09:04] adminen:create:functions:mailresume [29.08.2020 11:33] sophia.schauer
Line 91: Line 91:
 mailResume('ABCDE123', 3, 0); mailResume('ABCDE123', 3, 0);
 </code> </code>
 +
 +
 +===== Serial Mail After Opt-In Question =====
 +
 +With a question of type [[:en:create:questions:opt-in]] you can ask for e-mail addresses in the questionnaire and enter them directly into the address list (**Send invitations** -> **Address list**), so that you can send serial mails to the e-mail addresses later.
 +
 +This section explains how to use ''[[:en:create:functions:mailschedule]]'' to automatically trigger the scheduled or immediate sending of a serial mail to the entered e-mail address.
 +
 +There are two mechanisms for the opt-in question: The Double-Opt-In (the respondent must first confirm the address entry via confirmation email, recommended) and the Single-Opt-In, where the (possibly wrong) email address is stored directly.
 +
 +  - With Double-Opt-In it makes sense to trigger the dispatch only after confirmation of the mail address. How this works is explained in the following chapter: [[:/en:survey:opt-in-live]].
 +  - If you want to send the serial mail directly, you can use the confirmation mail of the (double-)opt-in question as invitation mail for a questionnaire at the same time (//Further settings// -> //Forwarding after confirmation// -> //Questionnaire link off//). However, the link in the confirmation email is only valid for 24 hours. A "real" serial mail invitation is usually valid for the entire survey period, unless the validity is limited in the serial mail settings.
 +  - If a "real" serial mail should be sent after a Single-Opt-In, the function ''mailSchedule()'' is used. This is explained in more detail below.
 +
 +The PHP code with the ''mailSchedule()'' is placed (at the earliest) on the page that follows the opt-in question. Only there the survey server knows the new e-mail address and has assigned it a personal ID (SERIAL). This personal ID is required as first parameter for the function ''mailSchedule()'' (as otherwise often used ''false'').Where do you get the ID from? If the respondent entered an email address in the opt-in question, it is noted in the record in a variable that has the same identifier as the opt-in question.
 +
 +In the following example, the opt-in question on page 9 would have the ID "OI01". On page 10 (or later) the following PHP code would then immediately send the serial mail with the ID 2. The ''value('OI01')'' returns the subscriber ID (SERIAL) of the new address entry.
 +
 +<code php>
 +mailSchedule(value('OI01'), 2, 0);
 +</code>
 +
 +The following PHP code would send the serial mail with the ID 3 after 14 days:
 +
 +<code php>
 +mailSchedule(value('OI01'), 3, strtotime('+7 days'));
 +</code>
 +
 +Of course you can also prepare several serial mails:
 +
 +<code php>
 +mailSchedule(value('OI01'), 2, 0);
 +mailSchedule(value('OI01'), 3, strtotime('+7 days'));
 +mailSchedule(value('OI01'), 4, strtotime('+14 days'));
 +</code>
 +
 +If there is a possibility that the respondent does not enter an e-mail address, an ''if'' should be added to avoid error messages:
 +
 +<code php>
 +$serial = value('OI01');
 +if ($serial) {
 +  mailSchedule($serial, 2, 0);
 +  mailSchedule($serial, 3, strtotime('+7 days'));
 +  mailSchedule($serial, 4, strtotime('+14 days'));
 +}
 +</code>
 +
 +Note that the personal ID (SERIAL) here is cached in a PHP variable (''$serial'') to be used directly in the ''mailSchedule()'' calls. Of course you could also use ''value('OI01')'' here
en/create/functions/mailresume.txt · Last modified: 21.04.2024 20:27 by admin
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki