Skip to content

Commit

Permalink
add AmpMail namesapce
Browse files Browse the repository at this point in the history
  • Loading branch information
mehedimi committed Jul 18, 2020
1 parent ae85feb commit 7eb249a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $ composer require mehedimi/laravel-amp-mail
```

## Quick Usages
To send amp email just use `Mehedi\Mimes\Amp` trait on your mail class and load amp view by using `amp` method.
To send amp email just use `Mehedi\AmpMail\Mimes\Amp` trait on your mail class and load amp view by using `amp` method.
### Example
```php
<?php
Expand All @@ -17,7 +17,7 @@ namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Mehedi\Mimes\Amp;
use Mehedi\AmpMail\Mimes\Amp;

class WelcomeEmail extends Mailable
{
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mehedimi/laravel-amp-mail",
"version": "1.0.0",
"version": "2.0.0",
"description": "Send amp mail through laravel mail",
"license": ["MIT"],
"authors": [
Expand All @@ -14,7 +14,7 @@
},
"autoload": {
"psr-4": {
"Mehedi\\": "src/"
"Mehedi\\AmpMail\\": "src/"
}
}
}
17 changes: 8 additions & 9 deletions src/Mimes/Amp.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Mehedi\Mimes;
namespace Mehedi\AmpMail\Mimes;

use Illuminate\Support\Facades\View;

Expand All @@ -25,21 +25,20 @@ public function amp($view, array $data = [])
$this->ampView = $view;
$this->viewData = array_merge($this->viewData, $data);

return $this;
return $this->addAmpPart();
}

/**
* Run the callbacks for the message.
* Register a callback for add amp part on message
*
* @param \Illuminate\Mail\Message $message
* @return $this
*/
protected function runCallbacks($message)
protected function addAmpPart()
{
parent::runCallbacks($message);

$message->getSwiftMessage()
->addPart($this->renderAmpView(), 'text/x-amp-html', 'utf-8');
$this->withSwiftMessage(function ($message) {
/** @var $message \Swift_Message */
$message->addPart($this->renderAmpView(), 'text/x-amp-html', 'utf-8');
});

return $this;
}
Expand Down

0 comments on commit 7eb249a

Please sign in to comment.