Mailer Gold and External Scripting Languages
With this capability, you can generate complex invoices with itemized detail, messages containing multiple attachments of source documents available to a customer, detailed scheduling information about upcoming events, and many other possibilites. Essentially, you have all the resources available in a powerful programming language all available within Mailer, which can manage the composition and sending of email for you. We think that's really cool!
To use this feature most effectively, you do need someone who can write the code to do the underlying data processing to produce your messages, but your developer doesn't have to worry about the details of email message handling, failed message management, and list management, and what's more, after a mailing is designed, someone else can perform the sending.
Preliminaries: Mailer's parsing process
When Mailer sends a mailing, the following steps happen:
It's important to know that if you are using an external langauge, you can use both external language syntax and Mailer syntax. In fact, your external language syntax can generate Mailer syntax commands, since Mailer's internal language processing happens afterwards. Why does Mailer's internal language processing happen at all? Because it's necessary in order for Mailer to properly process message filters and attachments, which are done with Mailer's command language syntax.
In order to use an external language with Mailer, you need to know the following things which are different for each external language:
You also need to know how Mailer handles errors that happen during processing, which is independent of external language usage. Here we will cover error handling, and then for each external language, we'll outline the three items above, and then illustrate with an example based on a common example scenario.
Standard Methods and Procedures
Mach5 Mailer provides these methods which you can use in your mailings. The sysntax to access these methods depends slightly on the scripting language that you use, but the examples will show how the syntax differs. The only real difference is that PHP uses a $ for variables and -> to access method members rather than the period used by VBScript and JScript.
Any of the commands can appear in the HTML or Plain Text portions of the mailing. They will have the same effect.
Mailer 3 Users: Note that the header and format commands are not available prior to Mailer 4.
Setting Up - choosing the scripting language
If you are using PHP, just point Mailer to the directory that contains "php.exe" on your system.
It's not a good idea to change scripting languages after your mailing is already set up! You can do it, but you will have to go in and edit all of the script that your mailing uses to change source languages.
If you have a syntax or database or other runtime error in your scripting, you need accurate information about that error. Mailer simply shoves the results of the external language script execution into the mailing. Whatever error reporting that the external language provides will be passed along directly in the preview window.
The test run feature can be useful to see if there are any glaring problems in your mailing. However, you need to step through your mailing at key records to make sure that you've cleared up any errors first.
Note that errors can show up both in the plaintext and html components of your mailing independently. Therefore it's best to preview both sections.
Post Process Scripting
Mailer Gold also has the ability to run a script after it tries to send a message. The scripting syntax and methods are the same as per-mailing scripting. See the documentation on post-process scripting for more info.
Example Scenario - Overview
Each external language section in this documentation includes an example which leverages off a common problem, outlined here.
Need: We need to send regular emails to our customers with updates about multiple jobs we do for them. At any point of time, each customer has one or more jobs in progress, and we would like to send overall report about status of all individual jobs. For simplicity suppose each customer has at least one active job. Each job may have a job report associated with it, and if it does, we want to send that job report to the customer as an attachment. As a result, an email may have no attachments, one or more attachments up to the number of jobs for the customer.
Data Sources: For this example we will have two different database tables. One table, the main one, contains customer information such as name, email address, customer ID, and other related information. This table will be the data source for the mailing. We will pull information about jobs in process from a second table through ODBC. The second table has a filename field in it for the job report to send, which is an empty string if there is no job report.
Result: The result of the mailing may produce a message like the following:
Producing the Result in Microsoft VBScript
VBScript creates and registers the following methods that you can use in your mailings:
Here's the source:
Here's the source:
Producing the Result in PHP
To use PHP, you need to tell Mailer which directory contains the php installation. This is the directory that contains the file php.exe. This information is stored in mail merge informatio, which is under the "Mail" menu. The General tab of the Mail Merge Information window indicates which scripting language to use, and for PHP, where the php installation is located. In many cases this location will simply be "C:\php4\" but it may be installed in a different place on your computer.
First, Mailer must do some character conversion to interface with PHP as follows:
PHP creates and registers the following methods that you can use in your mailings:
Here's the source:
Note that it is not necessary to be running a webserver on your system to use the PHP processing. PHP is a general scripting language and can be run independently of a browser environment. PHP is freely distributable and isn't included with the Mach5 Mailer package, but you can download and install it from http://www.php.net/