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 recipient in 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; a...
If you have gone through part 1 and done everything step by step then you are now ready to continue. We had already created an instance as shown below 👇 After instantiation, now you are ready to create a mail inside your code. Copy the code below: Let us now go through it step by step. $ mail -> isSMTP (); is to allow you send the mail using SMTP. $ mail-> SMTPAuth = true ; this is to enable SMTP authentication. $ mail-> SMTPSecure = 'tls' enable encryption, there are at least two types of encryption used by PHPMailer, PHPMailer:: ENCRYPTION_STARTTLS and TLS encryption. $ mail -> Port = 587 ; TCP port to connect to, that is if you have used TLS encryption, if you have opted for`PHPMailer::ENCRYPTION_SMTPS` then use port 465 $ mail -> isHTML ( true ); Sets an email format to HTML $ mail -> Username = 'vik03@username.ac.ke' ; SMTP username, hosts email address $ mail -> Password = 'secret...