Difference between #2 and #5 of
Using Apostle.io to send formatted, trackable emails from Yii applications

Changes

Title unchanged

Using Apostle.io to send formatted, trackable emails from Yii applications

Category unchanged

How-tos

Yii version changed

1.1

Tags changed

email, email

Content changed

> NOTE:
 
> Apostle.io was shut down on 30th of April 2019.
 
> They recommend SendGrid as a replacement service as it offer a templating system that uses moustache just like Apostle.io and should provide the simplest transition path from Apostle platform.
 
 
[Apostle](http://apostle.io) provides a nifty facility for sending app-generated, transactional emails from your application including Wordpress-like mail formatting and full tracking (delivery, opening, clicking etc.) of all emails sent. No need to set up email facilities on your app server!

Once you've figured your way round the dependencies, it's lovely and straightforward to integrate into a Yii application.
[...]
You then end up with a vendor directory (if you didn't have one already) containing apostle/apostle-php/src, guzzle/guzzle/src and symfony/event-dispatcher/Symfony. In your protected/config/main.php include aliases for each of their namespaces:


```php

Yii::setPathOfAlias('Apostle', dirname(__FILE__).'/../vendor/apostle/apostle-php/src/Apostle');
Yii::setPathOfAlias('Guzzle', dirname(__FILE__).'/../vendor/guzzle/guzzle/src/Guzzle');
[...]
also include an import line for the main Apostle module:


```php

// autoloading model and component classes
'import' => array(
[...]
Then, in whatever controller you're sending the email from, call the Apostle Module and set the domain key (only do this once), which you will get when you sign up to Apostle (it's free for up to 5,000 emails a month!).


```php

.........
Apostle::setup("1234567890abcdef1234567890abcdef");
[...]
Create an Apostle mail instance using a template that you have already set up using the Apostle site:


```php

........
$mail = new Apostle\Mail('welcome');
[...]
and add the email and any other values you want to use in your email


```php

.........
$mail->email = $model->email;
[...]
Finally, send it to Apostle....


```php

.....
// Send to Apostle.io
$mail->deliver();
```
[...]
2 1
2 followers
Viewed: 13 107 times
Version: 1.1
Category: How-tos
Tags: email, mail
Written by: MikeT
Last updated by: Maurizio Domba Cerin
Created on: Dec 9, 2013
Last updated: 4 years ago
Update Article

Revisions

View all history