Skip to end of metadata
Go to start of metadata

Sending transactional emails from your app with MailUp's SMTP relay

Below you can find some code samples showing how to send a transactional email using MailUp's SMTP relay service (SMTP+) from a client application. You can also send transactional messages using the MailUp API for transactional emails.

Disclaimer: no warranties on sample code

The code samples below are "as is", without warranty of any kind. MailUp shall not be held liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or other related to the example code.


That said, if you run into any issues, please contact us.

Also, let us know if you happen to create code that can be used with other programming languages, so that we can share it on this page (good karma!).


Using a reply-to address different from the sender address


The use inside the header of messages sent with SMTP+, of a REPLY-TO address different from the FROM email address must be enabled by MailUp. If you need this, please contact our support team by writing an email to

PHP code sample

This is a PHP snippet that requires PHPMailer and the credentials of a MailUp SMTP+ user.

PHP - Sending transactional emails using SMTP+

SMTP+: advanced features and sample code

Host domains

During the beta testing period of our SMTP+ service we added a new host domain ( for those who were interested in trying the new features in advance.

Now both the following host names provide exactly the same result:

  • (as suggested on MailUp admin console when creating a new SMTP+ user)


Advanced settings

Our SMTP relay service supports a X-SMTPAPI custom header that allows you to access several features by specifying additional parameters through a JSON object.

 Click here to learn more about X-SMTPAPI data format

The following table includes the parameters that can be added through X-SMTPAPI to override the settings that are defined at the MailUp list or at the SMTP+ user level. None of these fields is mandatory.

X-SMTPAPI value is processed by MailUp but it is not actually added to the headers of the delivered message.

Field nameDescription
String that is displayed as aggregate message name on admin console
String that is used for message aggregation,overrides list settings. When not specified, MailUp applies the aggregation type of used SMTP+ account
Boolean, overrides the list settings about adding default header or not.
Boolean, overrides the list settings about adding default footer or not.
Boolean, overrides the list settings about click tracking.
Boolean, overrides the list settings about open tracking.
Integer, from 1 (highest) to 5 (lowest), overrides SMTP+ account settings
Used to schedule send. An example of expected format is "2015-02-26T15:55+02:00". Send is immediate if field is equal to "null" or specifies a date-time that occurs in the past
Array of key-value pairs to be used as merge tags ("N" = name or key, "V" = value)

When this field is set to "true", placeholders (i.e. text between square brackets) are not managed as merge tags.


SkipDynamicFields= true -> [name] is not replaced by the recipient's name.
SkipDynamicFields= false, null or not specified -> [name] is replaced by the recipient's name.

Please note that MailUp specific tags like [email] and [idoptin] cannot be skipped, hence the "SkipDynamicFields= true" setting does not apply to them.


Use merge tags

Among the various important features, SMTP+ supports merge tags (also called dynamic fields in MailUp). 

You can use two kinds of merge tags:

  • merging values defined in recipient fields
  • merging values defined in the header of the message

In both cases, the syntax to be used in the message code is:

  • name of the tag in lowercase
  • between square brackets

For example, if you created a custom recipient field in your MailUp account called FirstName, the merge tag to use in the subject or body of the email message would be:

Merge tags based on recipient fields

You can merge tags for any of those recipient fields. Substitution occurs at the time the message issent, when those fields contain a value. Otherwise empty values will be displayed in place of the placeholder.

Merge tags based on value pairs defined in the message header

With SMTP+ you can reuse a message template (i.e. the same subject and body) and customize it with key-value pairs that are specified through custom headers added to the message. Also tables and HTML content can be used as a merge tag's value. 

Custom reports based on campaign code

In order to create meaningful statistics for transactional mailings, MailUp aggregates sending data based on a variety of parameters. For example, you can instruct the system to aggregate by message subject, or SMTP+ user, etc.

SMTP+ introduces the ability to aggregate sending data based on a custom CampaignCode parameter. This allows you to create a customized aggregation when none of the available options suits the desired behavior. 

For example, let's say that you wanted to aggregate sending statistics based on a specific keyword that is inside the message subject: there would be no way to meet your needs with the predefined aggregation options that are available in the SMTP+ settings within the MailUp admin console. 

The CampaignCode parameter comes to the rescue, allowing you to specify a code within the message header and force aggregation based on that code.

An additional parameter called CampaignName can be used to specify a name to be displayed on inside the MailUp admin console for those.

Message scheduling

Another important feature added with SMTP+ is support deferred sending. Specifically, you can now schedule a message so that it is sent at a specified date and time (with time zone).

Note: the message is sent immediately when the specified date and time has already occurred.

Combining instructions in the message header

Use commas as the separator for the X-SMTPAPI parameters that you wish to set in the message header.

  • No labels