It is very simple to emails directly from within your termplates.


The email object

hublify.email(...)

WIth this you can create an email object representing a single email to be sent. Later you apply the following functions onto the email object.

{# Set the to-email-address and send email #}
{% set myMailObj = hublify.email() %}

Alternativly you can pass all the data directly when instantiating the object

{# Build an object with some data already #}
{% set emailParams = {
  'to': 'info@hublify.io',
  'bodyText': 'See my text, from here!',
  'subject': 'Hello World!'
} %}

{# Instantiate the email object and directly pass some data #}
{% set myMailObj = hublify.email( emailParams ) %}

{# ... and send it! #}
{% do myMailObj.send() %}


Functions

Following function you can apply onto an email object.

to(...)

To set the email's TO address, you can use this function.

{# Set the to-email-address and send email #}
{% do hublify.email().to('info@hublify.io').send() %}


cc(...)

To set the email's CC address, you can use this function.

{# Set the cc-email-address #}
{% do hublify.email().cc('info@hublify.io') %}


bcc(...)

To set the email's BCC address, you can use this function.

{# Set the bcc-email-address #}
{% do hublify.email().bcc('info@hublify.io') %}


from(...)

To set the email's CC address, you can use this function.

{# Set the from-email-address #}
{% do hublify.email().from('info@hublify.io') %}


replyto(...)

To set the email's CC address, you can use this function.

{# Set the from-email-address #}
{% do hublify.email().replyto('info@hublify.io') %}


bodyHtml(...)

To set the email's CC address, you can use this function.

{# Set the body part (HTML) of the email #}
{% do hublify.email().bodyHtml('<h1>Hello World!</h1>') %}


bodyText(...)

To set the email's CC address, you can use this function.

{# Set the body part (Plain Text) of the email #}
{% do hublify.email().bodyText('Aloha, hello World!') %}


send(...)

To set the email's CC address, you can use this function.

{# Set the from-email-address #}
{% do hublify.email().from('info@hublify.io') %}


Examples

Simple Text-Email

To send a simple text email, set the TO-email and the plain text body and send it!

{% do hublify.email().to('info@hublify.io').bodyText('Wow, see my first email!').send() %}

Email-Object

Instead of directly chaining all the functions you can apply these of course directly onto the email-object itself.

{# Instantiate the email object #}
{% set myMailObj = hublify.email() %}

{# Now apply all functions individually #}
{% do myMailObj.to('info@hublify.io') %}
{% do myMailObj.bodyText('Wow, see my first email!') %}
{% do myMailObj.send() %}