PHPMailer Lite Examples
All of the links at the left are examples designed to show how to send emails using PHPMailer Lite version 2024.1.2.1 or higher. The advanced tests fully use Exception Handling and provide in-depth error messages.
Sendmail, Minimal Test
Demonstrates how to a send an email using Sendmail as email transport with the minimal setup. Note, when SetSender is not used, the email will show as sent from "No Reply" with email address "noreply@" and your domain name.
<html>
<head>
<title>PHPMailer Lite - SMTP (minimal)</title>
</head>
<body>
<?php
/*
* This test designed for PHPMailer Lite version 2024.1.2.1 and up ...
*/
// There are a number of ways to test your scripts. One of those is
// aboutmy.email test service ...
// if you prefer NOT to use a test service, please change
// the email addresses as you would like them to be for your tests
require_once('assets/lib/PHPMailer.Lite.php');
class_alias("codeworxtech\PHPMailerLite\PHPMailerLite", "PHPMailerLite");
$mail = new PHPMailerLite();
$mail->AddRecipient(['recipient@example.com'=>'Recipient Name']);
$mail->subject = "PHPMailer Lite Sendmail minimal test";
$mail->messageHTML = "<p>Test HTML message, minimal configuration.</p>";
if ($mail->Send('sendmail')) { //choose Sendmail as transport method
echo "Email sent successfully.<br>";
} else {
echo "Oops! Error sending email.<br>";
}
?>
</body>
</html>
Download example