Being that you are here, hope you have already gone through part 1 and 2 and now set to continue with the recipients settings.
Copy the code below then we go through it step by step.
$mail->setFrom('vik03@username.ac.ke',$dept); it has 2 options, first option is the senders email, second option is the mail header which is optional.$mail->AddAddress($result->EmailId); Add a recipient, you can also add a name as a second option but that is optional, I have stored the recipientin a variable but you can still key it in as a row text.This snippet have the variables used as part of the mail build up, PHP concatenation
and conditions have also played a part and trust me the library understands all this.$mail->Subject = $msg; here is where the email subject is written.Since we had already set the email format to HTML above by including this line, $mail->isHTML(true); we can continue to add the email body now$mail->Body = $body; add the body in a html format.If you do not intend to use HTML in the body then use $mail->AltBody = 'write here';After this, now your email is fully built and ready to be sent. Lets now send it.$mail->send(); This line of code sends the email that we have built.Congratulations, you now have a fully fledged code that can now send an email.Thanks for your time and hope you have been helped.Take your time to check PHPMailer github account for more clarity and understanding.Follow and share for more tech issues.Take your time and leave a comment. Thank you


Comments
Post a Comment