F
F
foobarsik2020-02-09 21:16:57
Laravel
foobarsik, 2020-02-09 21:16:57

How to send email via Postmark API?

Currently using SMTP

$this->mailer->send('emails.email-verification', ['user' => $user, 'redirectURI' => $redirectURI], function (Message $message) use ($user) {
            $message->to($user->email, $user->first_name);
            $message->subject('Verify your ArtDatabase Account.');
        });


And you need to send via API to make it faster, an example of sending from the Postmark docks:

$message = [
      'To' => "[email protected]",
      'From' => "[email protected]",
      'TrackOpens' => true,
      'Subject' => "A complex email",
      'TextBody' => "Plain Text Body",
      'HtmlBody' => "<html><body><img src=\"cid:attachment-file-name.jpg\"/></body></html>",
      'Tag' => "New Year's Email Campaign",
      'Headers' => [ "X-CUSTOM-HEADER" => "Header content"],
    'Attachments' => [$attachment]
  ];

  $client = new PostmarkClient("<server token>");

  $sendResult = $client->sendEmailBatch([$message]);


I can't figure out how to stuff the blade template into `HtmlBody`.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
foobarsik, 2020-02-09
@foobarsik

ok, it seems like it turned out to pull the html out of the template

view('emails.email-verification', ['user' => $user])->render()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question