From 474197aa2d3ad6c7aa98b54d7f9f8b5cafcb7575 Mon Sep 17 00:00:00 2001 From: Amigo <49749100+aamigo@users.noreply.github.com> Date: Wed, 12 Jun 2019 14:42:13 +0200 Subject: [PATCH] Updated 025 How to use email helper in your components (markdown) --- ...-to-use-email-helper-in-your-components.md | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/025-How-to-use-email-helper-in-your-components.md b/025-How-to-use-email-helper-in-your-components.md index f450f5b..a0db175 100644 --- a/025-How-to-use-email-helper-in-your-components.md +++ b/025-How-to-use-email-helper-in-your-components.md @@ -1 +1,24 @@ -Hi I want to show you how to use the emailing helper class in your component The email helper class is a class that gets added to your components helper area And therefore available on every page And with which you can then send emails We could look at the helper Class by going to a component that has it [00:00:25](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m25s) Included And then into helpers and The filename is usually the component name Email If've opened it already here As you can see it's in just the basic abstract class That That takes Joomlas emailer Which is this Jmail And it gets an instance of it [00:00:48](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m48s) And adds it to mail and then loads in the variables that's required Now We'll come back to this in a moment If you look at a component What you need to do first If you are gonna use this feature in any of your components Let us open this Learning manager And then go to libraries and helpers [00:01:22](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m22s) And you'll see that there add email helpers been set to on and that only Places the helper class in your component that's all it does It doesn't implemented anywhere else So At the moment that means that if you click yes here You need to still create fields That you are gonna load to your config area Now if you don't know about the config yet it means you've skipped some tutorials But it's basically this area here [00:01:55](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m55s) Which gives you the option to the ability to add Configuration options to your components option area So if we click here I scroll down you'll see that there is Mail configuration and a whole lot of fields there Now these Fields correspond to the Joomlas default Fields if you didn't know So if you would like to create these Fields and you need some info on what there should be in what should be their names and Everything Then go look at the Joomla Global configuration XML And you'll see all the settings in that file For our purposes I'm simply gonna show you how the fields look like [00:02:39](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m39s) We also have the dkim implementation available And even those Fields you will need to look at the code to know what their names should be So there's a difference of course between name and label and description When we refer to named and that is the The value that will be used in the code Ok I'll show you what I mean I just close out here Go back to the code So for example that word mailer [00:03:13](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m13s) Actually means That the name of the field is called Mailer The name of the field is called that and that and so it goes on So these are all the fields that needs to be set If if if your component If we go back to the component let me just Close this You would see there is a options area so I'm gonna open that once it open your see there is a mail configuration and a dkim area [00:03:45](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m45s) Dkim So let's open a mail You see that it has the mailer status So it's either set to off then no emails will go out or to on If it set to on you can decide whether you want to override the global function The global Variables now the global variables are set in your Joomlas components Global area [00:04:10](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m10s) So you would go to Global configurations And then You'd go to System No sorry It's server And then there's this mail settings here Ok Now these are the main or the the global settings that will be used in the in any component that Does not add [00:04:40](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m40s) These settings in their config So if you didn't create Those Fields and added it to your component but you ticked the the button to sort of add the helper Class to your component Then That means that it will basically fall back to these settings in your Joomla default Area So Just that you know And these are the values that you need to overwrite if you want your [00:05:08](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m08s) Component into some way to use other PHP mail or other send mail or Other What's the other one SMTP Values than that of the global you need to set it here And That is basically what this area can do So you use Global it falls back to the Joomla Global Otherwise you can overwrite it on this level And send it out In a way that is [00:05:38](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m38s) What you would like The DKIM area Is there more advanced area which basically allows you to overwrite Overwrite sorry not overwrite to encrypt And secure email sent out from you to authenticate that it was really you that send it This is very helpful to sort of show your the people that receive these emails that it's not Spam and it's really comes from you it's more advanced I would encourage you to read up on it these are the values Usually would be required to be added private key a public key And obviously these type of areas here If this is set to no obviously it will not be used if it set to yes please ensure to add the values [00:06:25](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m25s) Otherwise it still will not be used Ok So that's basically the values that you needs to still create Component does not do this for you You need to do it I could possibly foresee that In the future we might add this If you tick the helper class it adds these values for you But even then if you have done it manually We'll make sure that it doesn't add in twice [00:06:51](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m51s) So as long as These values obviously be the same Names we will know actually a Somehow identify that And then not Add them dynamically So to avoid clashes But for the meantime it's not automatically being added and so you need to do that manually if you want it To be there if you don't like I've said before It will fall back to the Joomla Global [00:07:15](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m15s) So to explain that you on the code level Basically it gets from the configuration The mailer function And then it checks whether it's global If it is global Then It Implements Joomlas Values If it's not Global it implements your components values [00:07:38](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m38s) And That is basically what it will do Now you can read through the code But the most important area really is this area To know what is all the various Options that you have in the signature To send out Mail So it's able to really send out a lot of mail but Nonetheless You're also need to consider [00:08:04](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m04s) You know Your servers own limitations Since we obviously don't want you to spam people We do not Overwrite those values. We are simply using the Joomla default Helper Joomla sorry jmailer And it is been extended from another class And so there are a lot of features and here And if you wanna know more about them you can read up on on obviously the jmailer [00:08:35](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m35s) Class from Joomla As well as read through this code here and see how we implemented These are the dkim values that you would need And in your In your component To be able to use the dkim encryption But you could also read up on this and check out this function here up till there In its way that it's implementing these features It obviously is adding it to the mailer and most of the work is done in the mailer [00:09:05](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m05s) So it's basically adding the data to the mailer and the mailer takes care of the rest Ok and so here it sends it off And if there is an error So let's say for some reason it didn't you know work out well Then it shakes whether Your Component Helper class So your component has a helper class it's just this file here [00:09:31](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m31s) Even has a storemessage Variable or method So if we were to go check this You see that there is the storemessage method In the helper class this is a custom method that I wrote now you can write it anywhere you like But this signature should be the same Ok so here Is the same signature you'll see it [00:10:00](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m00s) So basically this area that And that is dynamically updated to your component So it uses your component name here and your component name there But this store message Is basically Not You cannot change that but it takes to send email the recipient the subject the body to text only in the mode and it's says That it's email So you can have different types so if you look at the the method The type can be anything [00:10:30](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m30s) We are obviously wanting to do different things on different type so if we send an SMS and we didn't Fail You wanna store the message if we did this or that So this this kind of feature Is it only used when something didn't work But also if it worked If it was sent It's gonna store it So it's a way to store the message So that you can [00:10:57](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m57s) Maybe let your user go If they login They can see messages sent to them and this kind of stuff So this is what the store message does and as you see it's whole huge custom Method that I wrote And it does different things for different You can update it in change it pause the video copy it down don't really matter Just if you realize this is actually something you write up yourself you just need to make sure that that part is the same The rest is up to you Now you deal with it ok so that is really implementing the learning manager emailer [00:11:35](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m35s) In your component Maybe I should show you where I implemented at least In one area ok let me do that Ok so I have this component called job tracking system if I open it up You'll see that it actually has that function Adding the helper email it's got it selected you see there add helper Set it to on Then the view in which we are using the email method is the job or the view Basically we want to email the client I did job order [00:12:21](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m21s) When when it's created So let me show you how I implemented it there So here is the job order And I would basically then Click on This area here email now I can update that to whatever email I like Testing @ [00:12:45](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m45s) vdm.io or something Just send it in to Nothing And Then once the email has been sent It actually let's me know See there in the it says email was sent successfully So That's basically what the emailer does it just this button it sends this Document [00:13:11](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m11s) To my Client And also if I want to send it to my store The people that does the job I could also do that here I'm not gonna explain to you The reality of taking this content adding it to the email and sending it That I would suspect you need to know and you need to learn or study to do that yourself I'm I'm simply explaining to you how to use the email helper class So we will go to the code and I'll show you how I do it and [00:13:45](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m45s) Mostly Maybe I'll give you some pointers but I won't go into detail About how that is done Ok so let's go to the to the code So here we are in the job order So first thing here is obviously some JavaScript So there's the send email function and Gets a set of values And then it basically gives it over to the send Email server function which sends it as a J object [00:14:20](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m20s) Sorry a json request to the server The send Email is the Task And when it gets a response that's when you get the notification Ok so that's Simply the JavaScript of it So now if we go to PHP Previous Tutorials we explain how to use the Ajax class I'm gonna just touched on it briefly [00:14:47](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m47s) You basically have your input here This is where you put set up your controller Let me show you that So you'll see in your controller There is this send email Class that's what basically was defined And this field here And you see that there is Basically three variables And they are [00:15:12](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m12s) Should be filtered in this way and they are fast over to these methods And you should be logged in user So if you look at the code again it basically this is the task down here it triggers the task It checks for those values and then passes it over to This method which is in the Model is a model So we go to models Ajax So here is the the model let's just scroll down to the send email So here is the send email and this again [00:15:47](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m47s) Is a custom Script So if I was to go back here I Close this You'd see there's the in this Ajax method is a lot I mean look at that you can see that scroll down way down is a lot of other custom methods here But this is another custom method I've written Call send mail gets the mail the HTML to type It it does the necessary Cleansing and whatever [00:16:14](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m14s) And then It Basically Over Here We're calling the email helper We using the send method we Passing the valuables and we Set the result in here And if the results is obviously true [00:16:38](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m38s) We will let the user know otherwise we give him the error ok so that That is the The short end of it I'm also using this email body to help me build the the email because I want to Make sure that it's got all the necessary HTML and stuff so you can Pause this video and type that out if you like But this is the email body that I usually use and you can see you passing the HTML on the subject to it And it simply adds the the subject to the Email [00:17:15](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m15s) The necessary places as well as the body In the necessary place Right there So that it gets send in a way that's more appropriate And then That's all happening right here Ok and that is what I'm passing in here So a custom method which gets the data from the Ajax And then sends it off [00:17:43](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m43s) So that's a quick tutorial on how to implement sending emails through your component Using the email helper class Obviously the email helper class Is Available on GitHub in in the component Builder And if you feel that our implementation lacks some professional Help then please do make a commit to Quest or send me an email And we'll gladly update an improved this class Although I think we are followed All the necessary standard and requirements to make it useful to everyone [00:18:26](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m26s) Ok thanks for watching Until next time +# HOW TO USE EMAIL HELPER IN YOUR COMPONENTS + +* ### Example Of Email Helper Class + +Hi, I want to show you how to use the emailing helper class in your component. The email helper class is a class that gets added to your components helper area. And therefore available on every page. Which you can then send emails. We could look at the helper class by going to a component that has it [00:00:25](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m25s) included. Then into helpers. The filename is usually the component name: Email. I've opened it already. As you can see it's in the basic abstract class. That takes Joomla's emailer, which is this Jmail. It gets an instance of it, [00:00:48](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m48s) and adds it to mail and then loads in the variables that's required. We'll come back to this in a moment. + +### Setting Up Email Helper Class + +If you look at a component, what you need to do first, if you are going to use this feature in any of your components. Let us open Learning manager. Then go to libraries and helpers. [00:01:22](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m22s) You'll see that the add email helpers been set to on. It places the helper class in your component, that's all it does. It doesn't implemented anywhere else. At the moment that means that if you click yes here, you need to still create fields, that you are going to load your config area. + +### Settings - Config Area + +Now if you don't know about the config yet, it means you've skipped some tutorials, but it's basically this(config) area here. [00:01:55](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m55s) Which gives you the ability to add configuration options to your components option area. So if we click here(config - add) I scroll down you'll see that there is mail configuration and a whole lot of fields there. Now these fields correspond to the Joomla's default fields, if you didn't know. If you would like to create these fields and you need some info on what there should be in, what should be their names and everything. Then go look at the Joomla global configuration XML. And you'll see all the settings in that file. For our purposes I'm simply going to show you how the fields look like. [00:02:39](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m39s) We also have the DKIM implementation available. + +### In Code Field Names + +Even those fields you will need to look at the code to know what their names should be. So there's a difference of course between name and label and description. When we refer to name that is the value that will be used in the code. I'll show you what I mean. Go back to the code. For example that word mailer [00:03:13](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m13s) means that the name of the field is called mailer. The name of the field is called that and that and so it goes on. So these are all the fields that needs to be set. + +### Component Global Options - Mail Configuration + +In your component there is a options area, I'm going to open that. Once it's open your see there is a mail configuration and a DKIM area. [00:03:45](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m45s) Let's open the mail. You will see that it has the mailer status. So it's either set to off, then no emails will go out, or to on. + +??? +If it set to on you can decide whether you want to override the global function, the global variables. now the global variables are set in your Joomlas components Global area [00:04:10](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m10s) So you would go to Global configurations And then You'd go to System No sorry It's server And then there's this mail settings here Ok Now these are the main or the the global settings that will be used in the in any component that Does not add [00:04:40](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m40s) These settings in their config So if you didn't create Those Fields and added it to your component but you ticked the the button to sort of add the helper Class to your component Then That means that it will basically fall back to these settings in your Joomla default Area So Just that you know And these are the values that you need to overwrite if you want your [00:05:08](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m08s) Component into some way to use other PHP mail or other send mail or Other What's the other one SMTP Values than that of the global you need to set it here And That is basically what this area can do So you use Global it falls back to the Joomla Global Otherwise you can overwrite it on this level And send it out In a way that is [00:05:38](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m38s) What you would like The DKIM area Is there more advanced area which basically allows you to overwrite Overwrite sorry not overwrite to encrypt And secure email sent out from you to authenticate that it was really you that send it This is very helpful to sort of show your the people that receive these emails that it's not Spam and it's really comes from you it's more advanced I would encourage you to read up on it these are the values Usually would be required to be added private key a public key And obviously these type of areas here If this is set to no obviously it will not be used if it set to yes please ensure to add the values [00:06:25](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m25s) Otherwise it still will not be used Ok So that's basically the values that you needs to still create Component does not do this for you You need to do it I could possibly foresee that In the future we might add this If you tick the helper class it adds these values for you But even then if you have done it manually We'll make sure that it doesn't add in twice [00:06:51](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m51s) So as long as These values obviously be the same Names we will know actually a Somehow identify that And then not Add them dynamically So to avoid clashes But for the meantime it's not automatically being added and so you need to do that manually if you want it To be there if you don't like I've said before It will fall back to the Joomla Global [00:07:15](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m15s) So to explain that you on the code level Basically it gets from the configuration The mailer function And then it checks whether it's global If it is global Then It Implements Joomlas Values If it's not Global it implements your components values [00:07:38](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m38s) And That is basically what it will do Now you can read through the code But the most important area really is this area To know what is all the various Options that you have in the signature To send out Mail So it's able to really send out a lot of mail but Nonetheless You're also need to consider [00:08:04](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m04s) You know Your servers own limitations Since we obviously don't want you to spam people We do not Overwrite those values. We are simply using the Joomla default Helper Joomla sorry jmailer And it is been extended from another class And so there are a lot of features and here And if you wanna know more about them you can read up on on obviously the jmailer [00:08:35](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m35s) Class from Joomla As well as read through this code here and see how we implemented These are the dkim values that you would need And in your In your component To be able to use the dkim encryption But you could also read up on this and check out this function here up till there In its way that it's implementing these features It obviously is adding it to the mailer and most of the work is done in the mailer [00:09:05](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m05s) So it's basically adding the data to the mailer and the mailer takes care of the rest Ok and so here it sends it off And if there is an error So let's say for some reason it didn't you know work out well Then it shakes whether Your Component Helper class So your component has a helper class it's just this file here [00:09:31](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h09m31s) Even has a storemessage Variable or method So if we were to go check this You see that there is the storemessage method In the helper class this is a custom method that I wrote now you can write it anywhere you like But this signature should be the same Ok so here Is the same signature you'll see it [00:10:00](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m00s) So basically this area that And that is dynamically updated to your component So it uses your component name here and your component name there But this store message Is basically Not You cannot change that but it takes to send email the recipient the subject the body to text only in the mode and it's says That it's email So you can have different types so if you look at the the method The type can be anything [00:10:30](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m30s) We are obviously wanting to do different things on different type so if we send an SMS and we didn't Fail You wanna store the message if we did this or that So this this kind of feature Is it only used when something didn't work But also if it worked If it was sent It's gonna store it So it's a way to store the message So that you can [00:10:57](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h10m57s) Maybe let your user go If they login They can see messages sent to them and this kind of stuff So this is what the store message does and as you see it's whole huge custom Method that I wrote And it does different things for different You can update it in change it pause the video copy it down don't really matter Just if you realize this is actually something you write up yourself you just need to make sure that that part is the same The rest is up to you Now you deal with it ok so that is really implementing the learning manager emailer [00:11:35](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h11m35s) In your component Maybe I should show you where I implemented at least In one area ok let me do that Ok so I have this component called job tracking system if I open it up You'll see that it actually has that function Adding the helper email it's got it selected you see there add helper Set it to on Then the view in which we are using the email method is the job or the view Basically we want to email the client I did job order [00:12:21](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m21s) When when it's created So let me show you how I implemented it there So here is the job order And I would basically then Click on This area here email now I can update that to whatever email I like Testing @ [00:12:45](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m45s) vdm.io or something Just send it in to Nothing And Then once the email has been sent It actually let's me know See there in the it says email was sent successfully So That's basically what the emailer does it just this button it sends this Document [00:13:11](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m11s) To my Client And also if I want to send it to my store The people that does the job I could also do that here I'm not gonna explain to you The reality of taking this content adding it to the email and sending it That I would suspect you need to know and you need to learn or study to do that yourself I'm I'm simply explaining to you how to use the email helper class So we will go to the code and I'll show you how I do it and [00:13:45](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m45s) Mostly Maybe I'll give you some pointers but I won't go into detail About how that is done Ok so let's go to the to the code So here we are in the job order So first thing here is obviously some JavaScript So there's the send email function and Gets a set of values And then it basically gives it over to the send Email server function which sends it as a J object [00:14:20](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m20s) Sorry a json request to the server The send Email is the Task And when it gets a response that's when you get the notification Ok so that's Simply the JavaScript of it So now if we go to PHP Previous Tutorials we explain how to use the Ajax class I'm gonna just touched on it briefly [00:14:47](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m47s) You basically have your input here This is where you put set up your controller Let me show you that So you'll see in your controller There is this send email Class that's what basically was defined And this field here And you see that there is Basically three variables And they are [00:15:12](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m12s) Should be filtered in this way and they are fast over to these methods And you should be logged in user So if you look at the code again it basically this is the task down here it triggers the task It checks for those values and then passes it over to This method which is in the Model is a model So we go to models Ajax So here is the the model let's just scroll down to the send email So here is the send email and this again [00:15:47](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h15m47s) Is a custom Script So if I was to go back here I Close this You'd see there's the in this Ajax method is a lot I mean look at that you can see that scroll down way down is a lot of other custom methods here But this is another custom method I've written Call send mail gets the mail the HTML to type It it does the necessary Cleansing and whatever [00:16:14](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m14s) And then It Basically Over Here We're calling the email helper We using the send method we Passing the valuables and we Set the result in here And if the results is obviously true [00:16:38](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h16m38s) We will let the user know otherwise we give him the error ok so that That is the The short end of it I'm also using this email body to help me build the the email because I want to Make sure that it's got all the necessary HTML and stuff so you can Pause this video and type that out if you like But this is the email body that I usually use and you can see you passing the HTML on the subject to it And it simply adds the the subject to the Email [00:17:15](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m15s) The necessary places as well as the body In the necessary place Right there So that it gets send in a way that's more appropriate And then That's all happening right here Ok and that is what I'm passing in here So a custom method which gets the data from the Ajax And then sends it off [00:17:43](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h17m43s) So that's a quick tutorial on how to implement sending emails through your component Using the email helper class Obviously the email helper class Is Available on GitHub in in the component Builder And if you feel that our implementation lacks some professional Help then please do make a commit to Quest or send me an email And we'll gladly update an improved this class Although I think we are followed All the necessary standard and requirements to make it useful to everyone [00:18:26](https://www.youtube.com/watch?v=tp6mMUTOF2Y&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h18m26s) Ok thanks for watching Until next time