Created
March 21, 2016 15:01
-
-
Save Mevrael/1b7cca94db3fbda47b9a to your computer and use it in GitHub Desktop.
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
<?php namespace App\Core; | |
use Illuminate\Support\Facades\Lang; | |
use Pelago\Emogrifier; | |
class Mailer extends \Illuminate\Mail\Mailer | |
{ | |
/** | |
* Send a new message using a view. | |
* | |
* @param string $email_to | |
* @param string $view | |
* @param array $data | |
* @return void | |
*/ | |
public function sendTo($email_to, $view, array $data = []) | |
{ | |
$subject = Lang::get('mail.'.$view); | |
parent::send( | |
'emails.' . $view, | |
$data, | |
function ($message) use ($email_to, $subject) { | |
$message->to($email_to); | |
$message->subject($subject); | |
} | |
); | |
} | |
/** | |
* Render the given view. | |
* | |
* @param string $view | |
* @param array $data | |
* @return string | |
*/ | |
protected function getView($view, $data) | |
{ | |
$content = $this->views->make($view, $data)->render(); | |
$css = file_get_contents(resource_path('assets/css/email.css')); | |
$inliner = new Emogrifier(); | |
$inliner->setCss($css); | |
$inliner->setHtml($content); | |
$content = $inliner->emogrify(); | |
return $content; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment