Send Email using SMTP

Pre-requisites: Basic Understanding HTML, PHP and OOP.
In this project,
- Send an email using SMTP.
Code Explanation of mail.php |
use PHPMailerPHPMailerSMTP; use PHPMailerPHPMailerException;
|
|
|
$mail->SMTPAuth = true; $mail->Username = 'user@example.com'; $mail->Password = 'pwd';
|
$mail->addAddress('smith@example.com', 'Smith'); //Add a recipient $mail->addAddress('chris@example.com'); //Name is optional $mail->addReplyTo('john@example.com', 'Message'); $mail->addCC('cc@example.com'); $mail->addBCC('bcc@example.com');
|
$mail->Body = 'HTML message body'; $mail->AltBody = 'Message body in plain text'; $mail->send();
|
Summary
In this project, we have learned to send an email using SMTP.
Predefined classes are imported and an instance of PHPMailer is created and is used to define the mail parameters and finally then mail is sent using send() method.