-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
81 additions
and
28 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<<<<<<< HEAD | ||
Email autoresponder | ||
=================== | ||
Extension help send email | ||
This extension help send emails. | ||
|
||
Installation | ||
------------ | ||
|
@@ -11,26 +10,53 @@ The preferred way to install this extension is through [composer](http://getcomp | |
Either run | ||
|
||
``` | ||
php composer.phar require --prefer-dist pceuropa/yii2-email-autoresponder "*" | ||
composer require pceuropa/yii2-email "*" | ||
``` | ||
|
||
or add | ||
|
||
``` | ||
"pceuropa/yii2-email-autoresponder": "*" | ||
"pceuropa/yii2-email": "*" | ||
``` | ||
|
||
to the require section of your `composer.json` file. | ||
|
||
|
||
Configuration | ||
------------- | ||
|
||
Yii2 config file: | ||
```json | ||
'components' => [ | ||
'mailer' => [ | ||
'class' => 'yii\swiftmailer\Mailer', | ||
'viewPath' => '@common/mail', // basic Yii2: @app/mail | ||
'useFileTransport' => false, | ||
'transport' => [ | ||
'class' => 'Swift_SmtpTransport', | ||
'host' => 'smtp.gmail.com', | ||
'username' => '[email protected]', | ||
'password' => 'password', | ||
'port' => '587', // or 465 | ||
'encryption' => 'tls', // or ssl | ||
] | ||
], | ||
] | ||
``` | ||
|
||
Usage | ||
----- | ||
|
||
Once the extension is installed, simply use it in your code by : | ||
|
||
```php | ||
<?= \pceuropa\emailAutoresponder\AutoloadExample::widget(); ?>``` | ||
======= | ||
# yii2-email-autoresponder | ||
Extension help send email | ||
>>>>>>> 8ef6c3bc93e1f70f8ad265df4c607f2db25c82f7 | ||
use pceuropa\email\Send; | ||
|
||
Send::widget([ | ||
'from' => '[email protected]', | ||
'to' => '[email protected]', | ||
'subject' => 'subject email', | ||
'textBody' => 'Hello Lorem Ipsum. Bye', | ||
]); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
#Copyright (c) 2017 Rafal Marguzewicz pceuropa.net | ||
namespace pceuropa\email; | ||
use Yii; | ||
use yii\validators\EmailValidator; | ||
|
||
|
||
class Send extends \yii\base\Widget{ | ||
|
||
public $from = null; | ||
public $to = null; | ||
public $subject = null; | ||
public $textBody = null; | ||
|
||
public function init() { | ||
parent::init(); | ||
if ($this->to === null) { | ||
Yii::$app->session->setFlash('error', 'Please set recipient\'s email'); | ||
} | ||
} | ||
|
||
public function run() { | ||
$validator = new \yii\validators\EmailValidator(); | ||
|
||
if ( $this->to && $validator->validate($this->to) ){ | ||
|
||
$message = Yii::$app->mailer->compose() | ||
->setFrom($this->from) | ||
->setTo($this->to) | ||
->setSubject($this->subject) | ||
->setTextBody($this->textBody); | ||
|
||
$message->send(); | ||
} | ||
|
||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
{ | ||
"name": "pceuropa/yii2-email-autoresponder", | ||
"description": "Extension help send email", | ||
"name": "pceuropa/yii2-email", | ||
"description": "Widget help send email. Have validate input email.", | ||
"type": "yii2-extension", | ||
"keywords": ["yii2","extension"," email"," autoresponder"], | ||
"license": "MIT", | ||
"version": "1.0.1", | ||
"minimum-stability": "dev", | ||
"authors": [ | ||
{ | ||
"name": "Rafal Marguzeucz", | ||
"name": "Rafal Marguzewicz", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"yiisoft/yii2": "~2.0.0" | ||
"yiisoft/yii2": "~2.0.0", | ||
"yiisoft/yii2-swiftmailer": "^2.0@dev", | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"pceuropa\\emailAutoresponder\\": "" | ||
"pceuropa\\email\": "" | ||
} | ||
} | ||
} |