Skip to content

Commit

Permalink
change name and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pceuropa committed Feb 27, 2017
1 parent 3bf8977 commit 92cb0f7
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 28 deletions.
14 changes: 0 additions & 14 deletions AutoloadExample.php

This file was deleted.

44 changes: 35 additions & 9 deletions README.md
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
------------
Expand All @@ -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',
]);
```

39 changes: 39 additions & 0 deletions Send.php
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();
}

}
}

?>
12 changes: 7 additions & 5 deletions composer.json
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\": ""
}
}
}

0 comments on commit 92cb0f7

Please sign in to comment.