How can we help?

How can I further reduce email file size?


The file size of rendered email messages can be a factor in how the receiving email client displays them. For example, Gmail may clip email messages if a predetermined file size is exceeded. Other email clients may have strict spam rules that filter messages based on file size, which may affect deliverability.

You can use the Smarty {capture} tags to further reduce the resulting email size. Content between the capture tags is stored in a variable, giving you the opportunity to output those values or choose not to render them as part of a message.

The capture tags are ideal for Smarty logic that repeatedly iterates through data and does not output any valid HTML. This logic can add unnecessary bulk to your messages in form of carriage returns, whitespaces, code comments, and other content not intended for email recipients to see.

Capture tags should only be used to surround the Smarty business logic and not the logic used to render data in a message. Always preview and test your messages when using capture tags as removing whitespaces can affect rendered messages.


An example of using {capture} tags around the {foreach} statement that does not output message content:

{capture 'blackhole'}
{foreach $data as $key => $value}
  {$foo[$key] = $value}

The capture tag accepts the optional name attribute as the first argument, which we are using to add the custom label 'blackhole'. In our example, capture tags with this name are reserved for hidden content that will not be rendered.

We omit the capture tags for Smarty logic that will display message content:

<ul>{foreach $foo as $key => $value}



Please sign in to leave a comment.