1
00:00:01,470 --> 00:00:07,140
So now that we know how to send mail, let's implement that where it needs to be in our application

2
00:00:07,470 --> 00:00:13,260
and I'm looking at my roots file right now and the most obvious place where you need to send notifications

3
00:00:13,260 --> 00:00:21,080
both to the property owner and to the guest who's made the reservation is right here when you post make

4
00:00:21,090 --> 00:00:21,800
reservation.

5
00:00:21,810 --> 00:00:22,860
So let's look at that.

6
00:00:23,850 --> 00:00:27,360
So here in post reservation, the first thing we do is pass the form.

7
00:00:27,900 --> 00:00:31,950
Then we get the start date and end date and all of those things.

8
00:00:32,250 --> 00:00:38,550
And at the very bottom, after we check our validation, after we insert the reservation, and after

9
00:00:38,550 --> 00:00:45,810
we insert the restriction, just before we redirect them to that page, here is where we want to send

10
00:00:45,810 --> 00:00:46,620
notifications.

11
00:00:48,120 --> 00:00:52,890
So I'm going to go back to my main program and I have this I'm going to copy.

12
00:00:52,890 --> 00:00:55,190
I'm going to uncommented this and then cut it.

13
00:00:55,800 --> 00:00:58,130
That's where we send a sample of sending mail.

14
00:00:58,140 --> 00:01:04,610
And let's go back to our handlers and just paste that in there, send notifications first to guest.

15
00:01:04,620 --> 00:01:07,350
So I want to send this notification to the guest.

16
00:01:08,010 --> 00:01:15,300
So, too, would be not John A.K. but instead I already have the reservation right here and I have the

17
00:01:15,300 --> 00:01:19,170
email so I can just use that value down here.

18
00:01:19,170 --> 00:01:26,940
I'll change John Doe dot s.a to reservation dot email from would be whatever you want to specify your

19
00:01:26,940 --> 00:01:27,990
from as.

20
00:01:27,990 --> 00:01:35,490
I'll just leave it as that the subject will be reservation confirmation and now we need to build better

21
00:01:35,490 --> 00:01:39,900
spelled confirmation, write confirmation and we just need to build the content.

22
00:01:39,900 --> 00:01:43,640
So let's do that right here before we actually send the message.

23
00:01:44,040 --> 00:01:46,440
And this is not going to be a up Milchan.

24
00:01:46,470 --> 00:01:50,030
It will be m dot app dot mail champ.

25
00:01:50,610 --> 00:01:54,060
So all I need to do now is replace content with some string that I built.

26
00:01:54,060 --> 00:01:55,020
So I'll build a string.

27
00:01:55,980 --> 00:02:04,140
HTML message is assigned the value of and I'll use Batek so I can put this however I want to and then

28
00:02:04,140 --> 00:02:10,180
I'll change my content down here to HTML message and in here I just put the content that I want.

29
00:02:10,320 --> 00:02:11,880
So what do I want to put in there.

30
00:02:11,910 --> 00:02:22,050
Well let's do it as a format print f so I can actually substitute values from my reservation in the

31
00:02:22,050 --> 00:02:22,850
message itself.

32
00:02:23,340 --> 00:02:24,990
So this is going to be HTML.

33
00:02:24,990 --> 00:02:26,220
I'll make it very, very simple.

34
00:02:28,110 --> 00:02:35,850
I will put this as strong reservation con for nation strong.

35
00:02:39,470 --> 00:02:51,950
And then a line break and then I'll put deer percent s comma and then a line break this.

36
00:02:54,530 --> 00:03:06,920
Is to confirm your reservation from, but from and then I'll put another string to.

37
00:03:08,940 --> 00:03:12,450
Percent, yes, and that's all I'm going to put in there for now, you can substitute whatever you want.

38
00:03:13,140 --> 00:03:20,160
Now, these start date and end dates, of course, I can get that from a reservation start date.

39
00:03:23,220 --> 00:03:31,500
Short format and Melior will be 2006 two zero one zero two and the last place holder or the second or

40
00:03:31,500 --> 00:03:39,600
the first place place holder has to be their name, reservation, first name, and then the end date

41
00:03:40,170 --> 00:03:47,640
reservation and date that format, 26 zero one zero two.

42
00:03:49,200 --> 00:03:51,780
And that should send an email confirmation to the guest.

43
00:03:51,810 --> 00:03:52,700
So let's try this out.

44
00:03:53,010 --> 00:03:55,770
So I'm going to start my application run.

45
00:03:59,980 --> 00:04:04,870
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

46
00:04:04,870 --> 00:04:06,340
hogge localhost.

47
00:04:08,460 --> 00:04:14,450
1825, hopefully it's running, we're about to find out it is and there's no mail in there, and now

48
00:04:14,460 --> 00:04:19,140
I'll go to localhost 80 and make a reservation.

49
00:04:20,580 --> 00:04:23,910
So let's book a reservation, make a reservation now.

50
00:04:23,910 --> 00:04:29,430
So I'll search for the availability in some month that I'm pretty sure is available March 2nd to March

51
00:04:29,430 --> 00:04:29,940
3rd.

52
00:04:30,750 --> 00:04:31,880
Search availability.

53
00:04:32,070 --> 00:04:33,510
I'll stay in the major suite.

54
00:04:33,990 --> 00:04:35,690
And my first name is Bruce.

55
00:04:35,910 --> 00:04:37,370
My last name is Wayne.

56
00:04:37,590 --> 00:04:44,520
My email is Bruce at Bat Cave Dotcom and my phone number is whatever.

57
00:04:46,500 --> 00:04:49,290
Make the reservation reservation summary.

58
00:04:49,920 --> 00:04:51,570
Let's hope that sent the email.

59
00:04:51,570 --> 00:04:55,020
And there it is, reservation confirmation when I click on it.

60
00:04:55,140 --> 00:04:56,400
Reservation confirmation.

61
00:04:56,410 --> 00:04:59,010
Dear Bruce, which I have a typo there but that's OK.

62
00:04:59,400 --> 00:05:06,420
This shows you that the email actually works now as an exercise for yourself.

63
00:05:06,720 --> 00:05:12,960
Try sending an email confirmation to the property owner which can have any dummy email you want and

64
00:05:12,960 --> 00:05:14,220
can say whatever you want.

65
00:05:14,400 --> 00:05:19,650
And it needs to be just a very short message that notifies the property owner that they have a new reservation.

66
00:05:20,040 --> 00:05:23,580
So you give that a try and the next lecture I'll show you how I would do it.

67
00:05:23,580 --> 00:05:25,020
And it's a very simple process.

68
00:05:25,020 --> 00:05:27,330
You should have no difficulty at all.
