How can one simplify the usage of phpMailer for basic email functionalities like sender, recipient, subject, and message?

To simplify the usage of phpMailer for basic email functionalities like sender, recipient, subject, and message, you can create a function that takes in these parameters and sets them in the phpMailer object. This way, you can easily send emails by calling this function with the necessary details.

<?php

require 'PHPMailer/PHPMailerAutoload.php';

function sendEmail($from, $to, $subject, $message) {
    $mail = new PHPMailer;
    $mail->setFrom($from);
    $mail->addAddress($to);
    $mail->Subject = $subject;
    $mail->Body = $message;

    if(!$mail->send()) {
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
        echo 'Message has been sent';
    }
}

// Usage
sendEmail('sender@example.com', 'recipient@example.com', 'Test Email', 'This is a test email message.');

?>