Email templates: Email template attachment

{attachment} is powerful template function can be used when creating email templates to attach files to emails. 

Usage


In email templates you wish to attach something, use following tag:


Available attributes:

Attribute NameTypeRequiredDescription
invoiceInvoice IDNoUse this if you want to attach invoices to your email. Do not mix with file and template
filepathNoPath to your file that you wish to attach, use absolute paths. Do not mix with invoice and template
templateintNoID of template to generate PDF document out of. Do not mix with invoice and file
namestringNoOverride filename that will be used for attached file

Generating & attaching PDF document "on-the-fly"


Using document templates created/customised in Settings→Billing→Document Templates you can generate PDF document with dynamic content and attach it to email. 

In template details you will be presented with usage of attachment function:

Note: In your document template you will have access to same variables as in email template that you're attaching pdf to.


Once you will define your pdf template contents you can attach it to email template using (Replace ID below with your actual template id) :


If you wish to assign additional variables from email, you can pass them as attribute to attachment function:

Then in your document templates you can refer to variable you've created as {$foo} {$bar}.



Attaching PDF invoices


In any email template you can attach PDF invoice if you know its id


Attaching any existing file


If you know file location in your HostBill filesystem you can attach it to your emails by passing absolute path to it in file attribute



You can also use variables in file path