2017-05-23 8 views
0

私は、Mailgun APIを通して電子メールを送るのを遅らせる方法を見つけました。外部のHTMLを何とか使ってメールに入れることができるのだろうか?Laravel with Mailgun timed messages

今、私はこのようにそれをやっている:

$mgClient->sendMessage($domain, array(
    'from' => 'XY<[email protected]>', 
    'to'  => 'XY<[email protected]>', 
    'subject' => trans('content.subject_confirm_event_registration'), 
    'html' => '<myHtmlCode />', 
    'o:deliverytime' => Carbon::now()->hours(2)->toRfc2822String() 
)); 

しかし、問題は、私は、コードの100行のように持っている複雑なものを、しようとすると、それも見ていないで、私は解決策を希望します私はそれに外部ファイルを置くことができる場所、それはこのようになりますように:

$mgClient->sendMessage($domain, array(
    'from' => 'XY<[email protected]>', 
    'to'  => 'XY<[email protected]>', 
    'subject' => trans('content.subject_confirm_event_registration'), 
    'html' => file.blade.php 
    'o:deliverytime' => Carbon::now()->hours(2)->toRfc2822String() 
)); 
+0

おそらく、laravelメーラーがお手伝いできますか? また、キューでメールを送信するのを遅らせることもできます。 – skido

+0

たぶん、Mailgunを使って私の背後に理由があります:) – Norgul

+0

しかし、laravelにはMailgun Swift Transportドライバがあります – skido

答えて

0

は手動view()->render()を使用してビューをレンダリングすることができます。

Illuminate\View\View::render()は、ビューの文字列の内容を返します。これはクラス '__toString()メソッドの中でも使用され、Viewオブジェクトをエコーすることができます。

$mgClient->sendMessage($domain, array(
    'from' => 'XY<[email protected]>', 
    'to'  => 'XY<[email protected]>', 
    'subject' => trans('content.subject_confirm_event_registration'), 
    'html' => view('some.template', $data)->render() 
    'o:deliverytime' => Carbon::now()->hours(2)->toRfc2822String() 
));