WEBVTT

NOTE Created by CaptionSync from Automatic Sync Technologies www.automaticsync.com

00:00:01.056 --> 00:00:03.236 align:middle
We're now sending emails for realsies.

00:00:03.526 --> 00:00:05.426 align:middle
Let's just double-check our links are working...

00:00:05.986 --> 00:00:10.096 align:middle
All good! Mailtrap can do more
than just deliver &amp; debug emails:

00:00:10.356 --> 00:00:13.026 align:middle
we can also track emails and email events.

00:00:13.536 --> 00:00:17.116 align:middle
Jump over to Mailtrap and
click "Email API/SMTP".

00:00:17.946 --> 00:00:21.206 align:middle
This dashboard shows us an
overview of each email we've sent.

00:00:21.676 --> 00:00:23.896 align:middle
Click "Email Logs" to see the full list.

00:00:24.416 --> 00:00:25.196 align:middle
Here's our email!

00:00:25.656 --> 00:00:27.146 align:middle
Click it to see the details.

00:00:27.866 --> 00:00:29.196 align:middle
Hey! This look familiar...

00:00:29.476 --> 00:00:32.076 align:middle
it's similar to the Mailtrap testing interface.

00:00:32.516 --> 00:00:35.696 align:middle
We can see general details,
a spam analysis and more.

00:00:36.196 --> 00:00:38.796 align:middle
But this is really cool: click "Event History".

00:00:39.426 --> 00:00:43.266 align:middle
This shows all the events that
happened during the flow of this email.

00:00:43.886 --> 00:00:48.216 align:middle
We can see when it was sent,
delivered, even opened by the recipient!

00:00:48.836 --> 00:00:52.796 align:middle
Each event has extra details, like
the IP address that opened the email.

00:00:53.216 --> 00:00:55.666 align:middle
Super useful for diagnosing email issues.

00:00:56.306 --> 00:01:00.036 align:middle
Mailtrap also has a link
tracking feature that, if enabled,

00:01:00.246 --> 00:01:02.436 align:middle
would show which links were
clicked in the email.

00:01:03.056 --> 00:01:05.846 align:middle
Back on the "Email Info" tab, scroll down a bit.

00:01:06.516 --> 00:01:08.566 align:middle
Notice that the "Category" is "missing".

00:01:09.036 --> 00:01:11.916 align:middle
This isn't actually a problem,
but a "category" is a string

00:01:11.916 --> 00:01:14.916 align:middle
that helps organize the different
emails your app sends.

00:01:15.496 --> 00:01:18.296 align:middle
This makes searching easier and
can give us interesting stats

00:01:18.296 --> 00:01:21.336 align:middle
like "how many user signup
emails did we send last month?".

00:01:22.126 --> 00:01:25.626 align:middle
Symfony Mailer calls this a
"tag" that you can add to emails.

00:01:26.036 --> 00:01:29.736 align:middle
The Mailtrap bridge takes this tag
and converts it to their "category".

00:01:30.196 --> 00:01:30.836 align:middle
Let's add one!

00:01:31.466 --> 00:01:36.736 align:middle
In TripController::show(),
after the email creation, write:

00:01:37.046 --> 00:01:43.566 align:middle
$email-&gt;getHeaders()-&gt;add(new
TagHeader()); - use booking as the name:

00:01:44.956 --> 00:01:48.436 align:middle
Mailer also has a special metadata
header that you can add to emails.

00:01:48.856 --> 00:01:52.706 align:middle
This is a free-form key-value
store for adding additional data.

00:01:53.376 --> 00:01:57.356 align:middle
The Mailtrap bridge converts these
to what they call "custom variables".

00:01:57.776 --> 00:02:02.636 align:middle
Let's add a couple: And: Attached

00:02:03.016 --> 00:02:08.466 align:middle
to every booking email is now a
customer and booking reference.

00:02:08.466 --> 00:02:16.466 align:middle
Awesome! To see how these'll look in Mailtrap,
jump over to our app and book a trip (remember,

00:02:16.646 --> 00:02:22.526 align:middle
we're still using production
sending so use your personal email).

00:02:22.526 --> 00:02:23.716 align:middle
Check our inbox...

00:02:23.716 --> 00:02:24.266 align:middle
here it is.

00:02:24.266 --> 00:02:29.606 align:middle
Back in Mailtrap, go back to the email logs...

00:02:29.726 --> 00:02:30.516 align:middle
and refresh...

00:02:31.096 --> 00:02:31.876 align:middle
there it is!

00:02:31.876 --> 00:02:38.386 align:middle
Click it. Now, on this "Email Info"
tab, we see our "booking" category!

00:02:39.856 --> 00:02:47.326 align:middle
Down a bit further, here's our
metadata or "custom variables".

00:02:47.866 --> 00:02:52.836 align:middle
To filter on the "category",
go to the email logs.

00:02:53.526 --> 00:02:56.116 align:middle
In this search box, choose "Categories".

00:02:56.186 --> 00:03:00.106 align:middle
This filter lists all the categories we've used.

00:03:00.106 --> 00:03:03.886 align:middle
Select "booking" and "Search".

00:03:04.566 --> 00:03:14.096 align:middle
This is already more organized than
the Jeffries tubes down in engineering!

00:03:14.686 --> 00:03:16.936 align:middle
So that's production email
sending with Mailtrap!

00:03:17.416 --> 00:03:21.906 align:middle
To make things easier for the next chapters,
let's switch back to using Mailtrap testing.

00:03:22.596 --> 00:03:28.136 align:middle
In .env.local, uncomment the Mailtrap
testing MAILER_DSN and comment

00:03:28.136 --> 00:03:30.336 align:middle
out the production sending MAILER_DSN.

00:03:31.036 --> 00:03:35.506 align:middle
Next, let's use Symfony Messenger
to send our emails asynchronously.

00:03:35.756 --> 00:03:36.676 align:middle
Ooo!

