1 00:00:00,520 --> 00:00:05,670 In the last video we continue working on our mailer class and we've gone through a lot of set up inside 2 00:00:05,670 --> 00:00:06,070 of your. 3 00:00:06,090 --> 00:00:09,470 And again I know some of this stuff is painful at this point. 4 00:00:09,480 --> 00:00:11,820 We have finished defining all these properties. 5 00:00:11,820 --> 00:00:17,920 We registered the body property with our class by calling on ad content. 6 00:00:17,940 --> 00:00:24,210 So this ad content was a function that was provided by the male base class right underneath that we 7 00:00:24,210 --> 00:00:26,100 called ad click tracking. 8 00:00:26,100 --> 00:00:31,830 That was a helper function that we defined later in the class and then we also just called our recipients 9 00:00:31,920 --> 00:00:36,370 which is going to be a nother helper function that we're going to define in the class. 10 00:00:36,420 --> 00:00:42,270 So some of these functions that we're calling in here I know it's just like extra extra confusing because 11 00:00:42,300 --> 00:00:45,150 ad content is provided by the base class. 12 00:00:45,270 --> 00:00:48,920 But you and I have defined and implemented these other two. 13 00:00:48,930 --> 00:00:54,090 So where does this stuff like get implemented by mail but where does it and where does some of it get 14 00:00:54,090 --> 00:00:55,680 implemented by us. 15 00:00:55,680 --> 00:01:01,250 Again that's the confusion that's kind of the pain of working with all this e-mail stuff. 16 00:01:01,270 --> 00:01:02,700 All right well what then mind. 17 00:01:02,880 --> 00:01:05,550 Enough complaining let's just get through this we're almost done. 18 00:01:05,550 --> 00:01:10,020 The last thing we have to do is implement this ad recipient's function. 19 00:01:10,020 --> 00:01:16,450 So this is going to be a function that you and I define to take and process this list of recipients. 20 00:01:16,470 --> 00:01:18,510 So just to kind of clarify what we're about to do. 21 00:01:18,540 --> 00:01:24,600 Because this entire step is going to be just a little bit confusing when we called format addresses. 22 00:01:24,600 --> 00:01:30,850 All we did was turn each recipient into one of these helper e-mail things right here. 23 00:01:30,900 --> 00:01:37,140 So this start recipients is an array of these helper objects right here. 24 00:01:37,140 --> 00:01:40,770 That is not the only thing that we have to do. 25 00:01:40,770 --> 00:01:45,780 However unfortunately we also have to now take this list of recipients we have to take this list of 26 00:01:45,970 --> 00:01:51,840 help or email objects and we have to actually add them to the mailer as well. 27 00:01:51,840 --> 00:01:55,860 So again this is another thing that we're doing kind of in two separate steps just like we did with 28 00:01:55,860 --> 00:01:57,450 the body property up here. 29 00:01:57,450 --> 00:02:03,000 We're doing some initial formatting and then we've got a helper method right here to then take that 30 00:02:03,000 --> 00:02:07,200 formatted list and somehow register it with the actual email. 31 00:02:07,200 --> 00:02:11,130 So let's take care of that right now down at the bottom of the file. 32 00:02:11,220 --> 00:02:19,800 We're going to add the ADD recipient's helper function this is another great place to like triple check 33 00:02:19,830 --> 00:02:24,050 your spelling on recipients because very easy to make a typo here. 34 00:02:24,930 --> 00:02:32,200 So in sign of here we're going to do another little bit of kind of strange strange send good stuff. 35 00:02:32,220 --> 00:02:40,310 We're going to say cons personal lives equals new helper Daut personalization. 36 00:02:40,350 --> 00:02:43,740 And obviously I'm going to ask you to triple check your spelling here. 37 00:02:43,740 --> 00:02:45,740 Very easy to make a typo. 38 00:02:46,290 --> 00:02:51,990 We're then going to iterate over our list of recipients that we have assigned to this recipients and 39 00:02:51,990 --> 00:02:57,600 for each recipient will make use of this personalized objects that we've just declared. 40 00:02:57,600 --> 00:03:07,350 So we're going to say this Daut recipients Daut for each and then for each recipient in their I want 41 00:03:07,350 --> 00:03:20,360 to personalize Daut add to the recipient and then finally this dot ad personalization we're going to 42 00:03:20,360 --> 00:03:24,920 pass in the personalized variable that we just declared. 43 00:03:24,920 --> 00:03:30,830 So essentially what we did here was we defined this personalized variable within iterated over the list 44 00:03:30,830 --> 00:03:34,370 of recipients that we had defined up here. 45 00:03:34,370 --> 00:03:37,870 So here's the start recipients. 46 00:03:38,110 --> 00:03:43,450 And then for each recipient and remember each recipient at this point is not a recipient model. 47 00:03:43,450 --> 00:03:48,350 It is the helper e-mail thing that we set up right here. 48 00:03:48,400 --> 00:03:54,210 So for each one of those take them and add them to the personalized object. 49 00:03:54,280 --> 00:03:59,650 And then after they've all been added to the personalized object call this ad Perle's personalization 50 00:03:59,740 --> 00:04:06,760 which is that function that is defined by the male base class and add the entire personalized object. 51 00:04:07,270 --> 00:04:12,160 Yes this stuff is just nasty but fortunately I get great news we're all done thank goodness. 52 00:04:12,420 --> 00:04:14,140 The stuff has been just disgusting. 53 00:04:14,200 --> 00:04:20,790 Really you know great it's fantastic because we are very flexible on rules around sending out e-mails. 54 00:04:20,800 --> 00:04:22,060 Very flexible. 55 00:04:22,060 --> 00:04:26,890 They are also in general very easy to get started with are also free and don't require a credit card. 56 00:04:26,890 --> 00:04:30,370 And so they really check a lot of the boxes off for stuff around. 57 00:04:30,430 --> 00:04:33,960 Doing a tutorial you know like we're in right now or doing a course very easy. 58 00:04:33,960 --> 00:04:38,760 It started with but the actual code that you have to write is just nasty nasty stuff. 59 00:04:38,920 --> 00:04:44,530 And honestly even though I'm presenting this to you very truly I kind of have a tough time of imagining 60 00:04:44,530 --> 00:04:49,780 how you can easily take this and customize it at some point in the future because it is some really 61 00:04:49,780 --> 00:04:54,760 nasty logic that we've added in here so you know I apologize that that's so nasty but this is kind of 62 00:04:54,760 --> 00:04:56,120 the reality of it. 63 00:04:56,260 --> 00:04:59,700 Now of course you're always free to check out many other options out there. 64 00:05:00,190 --> 00:05:05,440 And look at stuff around you know other providers like MailChimp or something like that and you can 65 00:05:05,440 --> 00:05:11,620 use one of them instead for your e-mail handling inside of a personal project of your own and in general 66 00:05:11,620 --> 00:05:15,910 you're going to end up with a similar structure to what we're doing here where you'll centralize all 67 00:05:15,910 --> 00:05:21,010 the objects or all this logic into a mailer class and then set up all these properties and then eventually 68 00:05:21,010 --> 00:05:21,960 send out the e-mail. 69 00:05:22,120 --> 00:05:28,810 But hopefully with another provider you might have some easier less obtuse set up than what you're essentially 70 00:05:28,810 --> 00:05:29,890 seeing here. 71 00:05:30,250 --> 00:05:33,700 Anyways I hope that you know this hasn't been too bad. 72 00:05:33,700 --> 00:05:35,650 So there's one last thing we have to do. 73 00:05:36,130 --> 00:05:40,810 We're going to in the next section we're going to make sure that we add in a function that we can call 74 00:05:41,080 --> 00:05:46,360 to take the initialized to Mailer and actually kind of like send it out and kind of send the thing and 75 00:05:46,950 --> 00:05:51,030 you know issue that e-mail essentially and say to everyone hey here's our e-mail. 76 00:05:51,070 --> 00:05:53,580 Take the survey or whatever you might want to do. 77 00:05:53,660 --> 00:05:56,880 So quick break and we'll tackle this in the next section.