mailSend('lead@example.com', 1);
Of course, the ''1'' must be replaced with the identifier/number of the mailing that is to be sent.
===== Example: Data to project management =====
A participant fills out a test, the point value was calculated in variable ''$points'' and should now be sent to an email address together with the participant ID (SERIAL) so that the researcher is automatically informed about completed tests.
For this purpose, a mailing (ID 1) was created under **Send invitations** -> **Mailings**, which has (among other things) the following content:
participant: %custom1%
test result: %custom2%
On the last page of the questionnaire the following PHP code would now be placed under the calculation of the points value (''$points'') to send the result to ''store@example.com''.
mailSend('store@example.com', 1, 0, NULL, caseSerial(), $points);
===== Example: Do not save email address =====
A colleague's email address should be requested in the interview, but not saved. An invitation should be sent to this email address with a reference to the current interview (case number CASE).
**Note:** This use case is usually easier to implement with a question of type [[:en:create:questions:email]] and without any PHP code. Here only an alternative solution using ''mailSend()'' is shown.
In order to get the email address, an HTML input field is put on page 5 in the questionnaire.
Colleague's email address:
On the next page in the questionnaire (no later!), the specified email address is read using ''[[:en:create:functions:readget]]'' and the mailing with the ID ''2'' will be sent to this email address. The current case number is attached in the URL to the questionnaire as a reference.
$email = readGET('email_colleague', false);
if (trim($email) !== '') {
$link = 'https://www.soscisurvey.de/PROJEKT/?r='.caseNumber();
mailSend($email, 2, 0, $link);
}
===== Data Protection Details =====
When using mailSchedule(), SoSci Survey stores the specified e-mail address until the time of sending.
The address (along the time when to send it) is stored in the database in which SoSci Survey also stores the questionnaires and the collected data.