Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/venoel/mailgunapi

Simple Mailgun API for Yii 1.x
https://github.com/venoel/mailgunapi

mailgun-api yii yii1

Last synced: 2 months ago
JSON representation

Simple Mailgun API for Yii 1.x

Awesome Lists containing this project

README

        

# Mailgun API for Yii 1.x #

## Introduction ##

This simple Yii extension allow send email in HTML format through Mailgun API. It is easy switch between sandbox and real domain.

Yii is a fast, secure, and efficient PHP framework. https://www.yiiframework.com/

Mailgun - Powerful APIs that enable you to send, receive and track email effortlessly. Powerful APIs that enable you to send,
receive and track email effortlessly. https://www.mailgun.com/

## Usage ##

Download Mailgun.php and place it in ```/protected/extension``` directory.

Set configuration.

```/protected/config/main.php```

```
'components'=>array(
...
'mailgun' => array(
'class' => 'ext.Mailgun',
'sandboxUrl' => 'https://api.mailgun.net/v3/',
'url' => 'https://api.mailgun.net/v3/',
'apikey' => '',
'useSandbox' => true,
),
...
);
```

In some controller
```
$mailgun = Yii::app()->mailgun;
$res = $mailgun->send('[email protected]','[email protected]','Hello','

Test1

');
var_dump($res,$mailgun->getStatus());
```

## Configuration ##

*class* - path to Mailgun.php

*sandboxUrl* - sandbox domain. See https://app.mailgun.com/app/domains

*url* - Your real domain. See https://app.mailgun.com/app/domains

*apikey* - See API key in Domain Information section.

*useSandbox* - switch between sandbox and real domain. If ```true``` *sandboxUrl* is used. If ```false``` *url* is used.

## Sending email ##

```send($from,$to,$subject,$htmlBody)``` Send email. Return ```true``` on success.

```getStatus()``` Get status of last request.