In the last video we continue working on our mailer class and we've gone through a lot of set up inside
of your.
And again I know some of this stuff is painful at this point.
We have finished defining all these properties.
We registered the body property with our class by calling on ad content.
So this ad content was a function that was provided by the male base class right underneath that we
called ad click tracking.
That was a helper function that we defined later in the class and then we also just called our recipients
which is going to be a nother helper function that we're going to define in the class.
So some of these functions that we're calling in here I know it's just like extra extra confusing because
ad content is provided by the base class.
But you and I have defined and implemented these other two.
So where does this stuff like get implemented by mail but where does it and where does some of it get
implemented by us.
Again that's the confusion that's kind of the pain of working with all this e-mail stuff.
All right well what then mind.
Enough complaining let's just get through this we're almost done.
The last thing we have to do is implement this ad recipient's function.
So this is going to be a function that you and I define to take and process this list of recipients.
So just to kind of clarify what we're about to do.
Because this entire step is going to be just a little bit confusing when we called format addresses.
All we did was turn each recipient into one of these helper e-mail things right here.
So this start recipients is an array of these helper objects right here.
That is not the only thing that we have to do.
However unfortunately we also have to now take this list of recipients we have to take this list of
help or email objects and we have to actually add them to the mailer as well.
So again this is another thing that we're doing kind of in two separate steps just like we did with
the body property up here.
We're doing some initial formatting and then we've got a helper method right here to then take that
formatted list and somehow register it with the actual email.
So let's take care of that right now down at the bottom of the file.
We're going to add the ADD recipient's helper function this is another great place to like triple check
your spelling on recipients because very easy to make a typo here.
So in sign of here we're going to do another little bit of kind of strange strange send good stuff.
We're going to say cons personal lives equals new helper Daut personalization.
And obviously I'm going to ask you to triple check your spelling here.
Very easy to make a typo.
We're then going to iterate over our list of recipients that we have assigned to this recipients and
for each recipient will make use of this personalized objects that we've just declared.
So we're going to say this Daut recipients Daut for each and then for each recipient in their I want
to personalize Daut add to the recipient and then finally this dot ad personalization we're going to
pass in the personalized variable that we just declared.
So essentially what we did here was we defined this personalized variable within iterated over the list
of recipients that we had defined up here.
So here's the start recipients.
And then for each recipient and remember each recipient at this point is not a recipient model.
It is the helper e-mail thing that we set up right here.
So for each one of those take them and add them to the personalized object.
And then after they've all been added to the personalized object call this ad Perle's personalization
which is that function that is defined by the male base class and add the entire personalized object.
Yes this stuff is just nasty but fortunately I get great news we're all done thank goodness.
The stuff has been just disgusting.
Really you know great it's fantastic because we are very flexible on rules around sending out e-mails.
Very flexible.
They are also in general very easy to get started with are also free and don't require a credit card.
And so they really check a lot of the boxes off for stuff around.
Doing a tutorial you know like we're in right now or doing a course very easy.
It started with but the actual code that you have to write is just nasty nasty stuff.
And honestly even though I'm presenting this to you very truly I kind of have a tough time of imagining
how you can easily take this and customize it at some point in the future because it is some really
nasty logic that we've added in here so you know I apologize that that's so nasty but this is kind of
the reality of it.
Now of course you're always free to check out many other options out there.
And look at stuff around you know other providers like MailChimp or something like that and you can
use one of them instead for your e-mail handling inside of a personal project of your own and in general
you're going to end up with a similar structure to what we're doing here where you'll centralize all
the objects or all this logic into a mailer class and then set up all these properties and then eventually
send out the e-mail.
But hopefully with another provider you might have some easier less obtuse set up than what you're essentially
seeing here.
Anyways I hope that you know this hasn't been too bad.
So there's one last thing we have to do.
We're going to in the next section we're going to make sure that we add in a function that we can call
to take the initialized to Mailer and actually kind of like send it out and kind of send the thing and
you know issue that e-mail essentially and say to everyone hey here's our e-mail.
Take the survey or whatever you might want to do.
So quick break and we'll tackle this in the next section.