First, what’s the difference between PHPMailer Pro and SMTPMailer?
PHPMailer Pro is a robust mail transport class designed to handle the needs of any
user or application ... including large mailing lists and databases as well as
single individual emails from website forms. PHPMailer supports your choice of
unauthenticated SMTP, authenticated SMTP, Sendmail, and mail().
SMTPMailer is designed to support unauthenticated SMTP and authenticated SMTP with
minimal configuration. If SMTP cannot be used, SMTPMailer will default to sendmail.
SMTPMailer is a new project (formerly known as MailSend). Like PHPMailer Pro, SMTPMailer is a mail transport class. SMTPMailer is has many properties and methods that are similar in name, but entirely different in approach. At approximately 50 Kb, it’s also one of the smallest full featured transport classes available.
How easy is it to send an SMTP email? Have a look at this sample below:
<?php
use codeworxtech\PHPMailerLite\PHPMailerLite;
require('src/PHPMailerLite.php');
$mail = new PHPMailerLite();
try {
$mail->SetSender( ["sender@domain.com" => "Sender Name" ] );
$mail->AddRecipient( ['recipient@domain.com'=>'Recipient Name'] );
$mail->Subject = "Test";
$mail->MessageHTML = "<p>test message</p>";
if ($mail->Send()) {
echo "Message has been sent.<br>\n";
}
} catch (Exception $e) {
echo $e->errorMessage();
}
?> ... that's it. No need to define SMTP server, no need to define port number.
It's that simple. And if the server you are using does not have a built in
SMTP server, SMTPMailer automatically switches to Sendmail.
SMTPMailer supports PHP7.4 (and up) and is licensed under MIT).