use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require 'vendor/autoload.php'; $mail = new PHPMailer(true); try { $mail->SMTPDebug = 2; $mail->isSMTP(); $mail->Host = 'smtp.example.com'; $mail->SMTPAuth = true; $mail->Username = 'user@example.com'; $mail->Password = 'mysupersecretpassword'; $mail->SMTPSecure = 'ssl'; $mail->Port = 465; $mail->setFrom('from@example.com', 'Sender Name'); $mail->addAddress('recipient@example.com', 'Recipient Name'); $mail->addReplyTo('reply@example.com', 'Reply Name'); $mail->isHTML(true); $mail->Subject = 'Example Subject'; $mail->Body = 'This is the message body'; $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo 'Message could not be sent. Error: ', $mail->ErrorInfo; }In this example, the PHPMailer library is used to send an email. The script sets the necessary SMTP settings, recipient, sender, and message body before attempting to send the email. If the email is successfully sent, the script will output a success message. Otherwise, it will output the error message returned by the PHPMailer library.