Tuesday, May 23, 2017

Laravel with Mailgun timed messages

I have found a way to delay sending e-mail through Mailgun API. I am wondering if external HTML can be used somehow to include in the mail?

Now I am doing it like this:

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

But the problem is when I try anything complex, which has like 100 lines of code, it doesn't look well, and I would like a solution where I can put external file in it so that it looks like this:

    $mgClient->sendMessage($domain, array(
        'from'    => 'XY<webmaster@xy.com>',
        'to'      => 'XY<xy@xy.com>',
        'subject' => trans('content.subject_confirm_event_registration'),
        'html'    => file.blade.php
        'o:deliverytime' => Carbon::now()->hours(2)->toRfc2822String()
    ));



via Norgul

Advertisement