So now that we know how to send mail, let's implement that where it needs to be in our application
and I'm looking at my roots file right now and the most obvious place where you need to send notifications
both to the property owner and to the guest who's made the reservation is right here when you post make
reservation.
So let's look at that.
So here in post reservation, the first thing we do is pass the form.
Then we get the start date and end date and all of those things.
And at the very bottom, after we check our validation, after we insert the reservation, and after
we insert the restriction, just before we redirect them to that page, here is where we want to send
notifications.
So I'm going to go back to my main program and I have this I'm going to copy.
I'm going to uncommented this and then cut it.
That's where we send a sample of sending mail.
And let's go back to our handlers and just paste that in there, send notifications first to guest.
So I want to send this notification to the guest.
So, too, would be not John A.K. but instead I already have the reservation right here and I have the
email so I can just use that value down here.
I'll change John Doe dot s.a to reservation dot email from would be whatever you want to specify your
from as.
I'll just leave it as that the subject will be reservation confirmation and now we need to build better
spelled confirmation, write confirmation and we just need to build the content.
So let's do that right here before we actually send the message.
And this is not going to be a up Milchan.
It will be m dot app dot mail champ.
So all I need to do now is replace content with some string that I built.
So I'll build a string.
HTML message is assigned the value of and I'll use Batek so I can put this however I want to and then
I'll change my content down here to HTML message and in here I just put the content that I want.
So what do I want to put in there.
Well let's do it as a format print f so I can actually substitute values from my reservation in the
message itself.
So this is going to be HTML.
I'll make it very, very simple.
I will put this as strong reservation con for nation strong.
And then a line break and then I'll put deer percent s comma and then a line break this.
Is to confirm your reservation from, but from and then I'll put another string to.
Percent, yes, and that's all I'm going to put in there for now, you can substitute whatever you want.
Now, these start date and end dates, of course, I can get that from a reservation start date.
Short format and Melior will be 2006 two zero one zero two and the last place holder or the second or
the first place place holder has to be their name, reservation, first name, and then the end date
reservation and date that format, 26 zero one zero two.
And that should send an email confirmation to the guest.
So let's try this out.
So I'm going to start my application run.
I will go back to my Web browser and I'll open two tabs on the first tab, I'm going to put my mail
hogge localhost.
1825, hopefully it's running, we're about to find out it is and there's no mail in there, and now
I'll go to localhost 80 and make a reservation.
So let's book a reservation, make a reservation now.
So I'll search for the availability in some month that I'm pretty sure is available March 2nd to March
3rd.
Search availability.
I'll stay in the major suite.
And my first name is Bruce.
My last name is Wayne.
My email is Bruce at Bat Cave Dotcom and my phone number is whatever.
Make the reservation reservation summary.
Let's hope that sent the email.
And there it is, reservation confirmation when I click on it.
Reservation confirmation.
Dear Bruce, which I have a typo there but that's OK.
This shows you that the email actually works now as an exercise for yourself.
Try sending an email confirmation to the property owner which can have any dummy email you want and
can say whatever you want.
And it needs to be just a very short message that notifies the property owner that they have a new reservation.
So you give that a try and the next lecture I'll show you how I would do it.
And it's a very simple process.
You should have no difficulty at all.