yii-mailgun Mailgun API PHP library and Yii extension

  1. Requirements
  2. How to install
  3. How to use

Mailgun is a programmable email platform. It allows your application to become a fully-featured email server. Send and receive messages, create mailboxes and email campaigns with ease.

Requirements ¶

The library requires PHP 5.2 or higher compiled with cURL extension.

How to install ¶

0. Install Composer:

~~~
curl -sS https://getcomposer.org/installer | php
~~~

0. Add php-mailgun dependency:

~~~
php composer.phar require baibaratsky/php-mailgun:*
~~~

How to use ¶

Just put php-mailgun in your extensions directory or use Composer, and add some code in the components section of your config file:

...
    'components' => array(
        ...
        'mailgun' => array(
            'class' => 'vendor.baibaratsky.php-mailgun.MailgunYii',
            'domain' => 'example.com',
            'key' => 'key-somekey',
            'tags' => array('yii'), // You may also specify some Mailgun parameters
            'enableTracking' => false,
        ),
        ...
    ),
...

That’s all! Your application is ready to send messages. For example:

$message = Yii::app()->mailgun->newMessage();
$message->setFrom('me@example.com', 'Andrei Baibaratsky');
$message->addTo('you@yourdomain.com', 'My dear user');
$message->setSubject('Mailgun API library test');

// You can use views to build your messages instead of setText() or setHtml():
$message->renderText('myView', array('myParam' => 'Awesome!'));

echo $message->send();

All the methods of the main library class are available in the Yii component.

0 0
1 follower
300 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Mail
Developed by: baibaratsky baibaratsky
Created on: Apr 27, 2015
Last updated: 10 years ago

Downloads

show all

Related Extensions