Hello, in this video we are going to take a look at sending emails using PHP mailer. So we've already set up PHP Mail app. If you haven't, haven't done that, I recommend checking out the setup video. Okay, so to send emails for new loads of newly scrolled send emails, it's placed in boys want to do a try block to a good to do try block just in case something failed and you can handle the exception. And then you get this mail variable which is you know, an object of mail and I'm going to be covering more about objects and object oriented programming now in a later part in this series, and just do set form and this is basically going to be where it's actually coming from, and I'll have a contact in Wk because the domain is Sona Inc, Dakota, UK. And now we're going to put like a name.
So the names on Say dark data, coffee data sent the email. Now we need to actually add who we are sending it to. So dollar mail and add address and this is basically the same format as well so the support of Soma systems Dr. tk, she's just my company support email address and who's sending it on to me. There we go. Next what we're gonna do is set the actual subject for dollar now your object is a T equals to something, I'm gonna say, force subject. Now we need to specify the actual body itself.
Dollar male body equals and then we say this is and now we just send it so dollar male thing. We just need to handle some exceptions. So catch. This one we're going to handle is this is going to be just a generic exception. And we are going to say echo, dollar a error message and we'll do one more really similar to this one. The only difference is going to force law backslash year I still get is the second one going to be get method now.
So the backslash is to select the global namespace exception plus so does you know extra error that we need to handle. So please save that. Same same saving, there we go. And this is the email address that I should receive here. And if I reload the page, we should receive it any moment now. There we go.
Darth Vader contact us. So now in there we go. And that's really all you need to know Jedi master classes per name there, and it's put the body so that is how you send a email using the old one. So you say using the gone blank now. He's impatient. So that's it.
If you have any questions, feel free to drop me a message. And as usual, I look forward to seeing you in the next video.