To use PHP scripts in your messages:

Choose Direct Mail > Preferences...

Click the Messages icon.

Check the "Execute PHP code in message body" check box.

Type your PHP code directly into the body of the message, surrounding the code with <?php ... ?>
tags.
The output of your PHP script will be merged back into message, replacing the original <?php ... ?>
tags. To print output from your script, use PHP's print
or echo
functions.
Scripts are run once per recipient. As such, scripts should run quickly to avoid slowing down mail delivery. Scripts running longer than 30 seconds will be terminated.
Scripts can access address list data for the current recipient using the $_DIRECTMAIL[]
PHP associative array variable. The keys of the array are identical to names of mail-merge tags. For example, <?php print $_DIRECTMAIL['first name']; ?>
outputs the first name of the current recipient.
To help you debug your PHP scripts, you can view a log of errors encountered during script execution. Choose Window > PHP Log.