Skip to content

Commit 7eb249a

Browse files
committed
add AmpMail namesapce
1 parent ae85feb commit 7eb249a

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $ composer require mehedimi/laravel-amp-mail
77
```
88

99
## Quick Usages
10-
To send amp email just use `Mehedi\Mimes\Amp` trait on your mail class and load amp view by using `amp` method.
10+
To send amp email just use `Mehedi\AmpMail\Mimes\Amp` trait on your mail class and load amp view by using `amp` method.
1111
### Example
1212
```php
1313
<?php
@@ -17,7 +17,7 @@ namespace App\Mail;
1717
use Illuminate\Bus\Queueable;
1818
use Illuminate\Mail\Mailable;
1919
use Illuminate\Queue\SerializesModels;
20-
use Mehedi\Mimes\Amp;
20+
use Mehedi\AmpMail\Mimes\Amp;
2121

2222
class WelcomeEmail extends Mailable
2323
{

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mehedimi/laravel-amp-mail",
3-
"version": "1.0.0",
3+
"version": "2.0.0",
44
"description": "Send amp mail through laravel mail",
55
"license": ["MIT"],
66
"authors": [
@@ -14,7 +14,7 @@
1414
},
1515
"autoload": {
1616
"psr-4": {
17-
"Mehedi\\": "src/"
17+
"Mehedi\\AmpMail\\": "src/"
1818
}
1919
}
2020
}

src/Mimes/Amp.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Mehedi\Mimes;
3+
namespace Mehedi\AmpMail\Mimes;
44

55
use Illuminate\Support\Facades\View;
66

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

28-
return $this;
28+
return $this->addAmpPart();
2929
}
3030

3131
/**
32-
* Run the callbacks for the message.
32+
* Register a callback for add amp part on message
3333
*
34-
* @param \Illuminate\Mail\Message $message
3534
* @return $this
3635
*/
37-
protected function runCallbacks($message)
36+
protected function addAmpPart()
3837
{
39-
parent::runCallbacks($message);
40-
41-
$message->getSwiftMessage()
42-
->addPart($this->renderAmpView(), 'text/x-amp-html', 'utf-8');
38+
$this->withSwiftMessage(function ($message) {
39+
/** @var $message \Swift_Message */
40+
$message->addPart($this->renderAmpView(), 'text/x-amp-html', 'utf-8');
41+
});
4342

4443
return $this;
4544
}

0 commit comments

Comments
 (0)