Post-Send Scripting in Mailer Gold
Mailer Gold allows you to execute a script after Mailer attempts to send each message. You can use this script to pass information back to your database about the status of each send attempt. You can also set Mailer to only pass information back to the database when Mailer successfully delivers the message to the server.
In your log file, a result code indicates what happened to each message. Here are the result codes:
Under the Mail menu choose Post-Process Script
You can specify what script to run after Mailer sends every message. You can also tell Mailer to execute the script only if it successfully delivers the message to the SMTP server.
Note that just because Mailer delivers the message to the server, that doesn't mean the message will be delivered to the recipient. But it does mean that Mailer has successfully sent the message to the relevant server.
Performance Issue: Because access to your data source must be sequential (you can't have several programs trying to update your data source at the same time), only one thread can run the post-process script at once. Mailer may send with 10 threads, but the post-process scripting happens one message at a time. For this reason, using post-process scripting may slow down your send operation. The performance penalty you experience depends upon the complexity of the script, the efficiency of the data source connection (Some ODBC drivers are slow), and the load on your machine.
Under the Mail Menu choose "Post-Process Script...". In this dialog, choose the script that you want to execute. Just as in PopMonger, all scripts must be surrounded by the Mailer external scripting delimiters <? and ?>. Mailer determines the kind of script to execute from the file extension in the same way that PopMonger does:
After you choose your script, you can also tell Mailer to only execute the script if Mailer successfully sends the message. If you turn off this option, Mailer will execute the post-send script even after failed delivery attempts.
The same $mailer context variable that is available to Mailer message content scripts is also available to post-processing scripts. One additional value is available for post-processing: $mailer->sendResult(). This function returns the status number for the message send attempt, so you can determine why the message was not sent if it failed. Available status codes are documented here:
Values returned by sendResult are as follows:
Determining if the operation is a test run
You can tell whether or not the mailing is from a Mailer "test run" also in your script. You can use a test run to test the functionality of your mailing, but if you are making a database operation during a live run, you may not want to actually change the database during a test run.
The testRun property returns true or false depending on whether or not the mailing is a test run.
For more information on scripting, please check out general scripting documentation.