// Require the PHPMailer autoloader require 'vendor/autoload.php'; // Initialize PHPMailer $mail = new PHPMailer; // Set the sender and recipient addresses $mail->setFrom('sender@example.com'); $mail->addAddress('recipient@example.com'); // Set the subject and body of the email $mail->Subject = 'Test Email'; $mail->Body = 'This is a test email.'; // Send the email if ($mail->send()) { echo 'Email sent successfully!'; } else { echo 'Error: ' . $mail->ErrorInfo; }
// Require the PHPMailer autoloader require 'vendor/autoload.php'; // Initialize PHPMailer $mail = new PHPMailer; // Set the sender and recipient addresses $mail->setFrom('sender@example.com'); $mail->addAddress('recipient@example.com'); // Set the subject and body of the email $mail->Subject = 'Test Email with Attachment'; $mail->Body = 'This is a test email with an attachment.'; // Attach a file to the email $mail->addAttachment('/path/to/file.pdf'); // Send the email if ($mail->send()) { echo 'Email sent successfully!'; } else { echo 'Error: ' . $mail->ErrorInfo; }Based on the `require 'vendor/autoload.php';` line in each example, it can be determined that PHPMailer is likely packaged as a Composer library.