Let's clear up context before we start into this subject. Which to use? means: Which to use TO SEND emails ... if you are designing an application that includes receiving emails, this article is not for you. This is specifically about sending emails.
The type of email you are sending is very important. It's pointless to use an advanced mailer if all you want is to send a quick notification (from yourself) about an event on your website (to yourself). In such a case, you have complete control over the content and email addresses. If you do not include any attachments in your email, all you really need is to create a plain text message. In such a case, send your email using PHP Mail(), IMAP, or even Sendmail.
Here's an example of a notification email:
<?php
$to = 'name@example.com';
$subject = 'Server Event Notification';
$message = <<<MSG
An important event from the website.
Notification sent via PHP mail().
MSG;
wordwrap($message, 70, "\r\n");
mail($to, $subject, $message, '-f ' . $to);
?>
This is quick, and it's simple.
If you go beyond this simplicity, like adding HTML portion, attachments, or inline graphics ... you really need to look at a more extensive script. At this point, it's worth considering an existing Mailer Transport class.
That's how I started. When I looked at all the emails my company was creating (or processing) for ourselves and clients, the decision was made to search out a Mail Transport script that could handle everything from a single email to large mailing list type quantities. There was already a significant knowledge base on email transport within our group ... but spending far too many valuable resources on constantly evolving email needs.
At that point, PHPMailer was fairly new. The code base was designed to handle everything we needed. Over a short period of time I was able to contribute to the original package ... but the package was floundering. I asked to take over the project. That's exactly what happened ... until 2012 when health altered my plans.
As of 2021, I am back to coding. As of 2023, I relaunched my Open Source projects, including a reboot of email projects including a new Mail Transport class known as PHPMailer Pro.
Unlike the original PHPMailer, PHPMailer Pro has SMTP transport built into the main code. There are now four transport types: SMTP, Sendmail, Mail, and IMAP. Everything is greatly simplified. You do not have to specificy how to transport, you can let PHPMailer Pro figure that out. There is a priority of transport methods starting with SMTP. The priorities are SMTP, Sendmail, IMAP, then Mail. If SMTP is unavailable, Sendmail is next. If Sendmail is unavailable, IMAP is next. If all three are unavailable, then we use Mail as the last attempt.
SMTP, by the way, is attempted with or without credentials. Without credentials, we send SMTP un-authenticated. With credentials, we send SMTP fully authenticated. And, to address a question about un-authenticated SMTP ... the other three possible transports are Sendmail, IMAP, and PHP Mail() – ALL UN-AUTHENTICATED. Un-authenticated does not pose any additional risks ... we still can't relay, we have to use critical email specifications that match the domain we are sending from. It's not a free-for-all ... there is protection.
If you decide to use the default SMTP transport, you do NOT have to specify port or mail server. We check and verify those before sending.
The original PHPMailer was written using PHP version 3. In its day, there was quite a few work arounds needed, classes were not really object oriented and error handling was at its most basic form. PHPMailer Pro is a redesign of the code in its entirety. The concepts designed into the original package no longer apply and many were unnecessary. For example, I recall writing the code to handle MsgHTML ... to that point users had to enter in both the text portion (alt body) and the HTML portion (body). MsgHTML was a step forward where the HTML was parsed into the text portion as well (if the text portion was not already defined). Plus, you still had to tell PHPMailer to process for HTML (isHTML) ... The world of parsing emails in email client software has progressed too. Today, many emails do not even include a text portion. PHPMailer Pro addresses that by having a property for text (messageText) and a property for HTML (messageHTML). The code to automatically convert HTML to a text message (if the text message is missing) is not longer pertinent and has been deprecated and removed. No messageText means the text portion of the email is still created, but left empty. No messageHTML means the HTML portion is NOT created. That does not mean empty messages are sent out ... we still check for attachments (inline or files) and send those even with no text or HTML components.
Entirely new starting with version 1.2.1 of PHPMailer Pro is the option to place a copy of the outbound email into the user's Sent mailbox. That's a feature that has been requested for years ... now, it's reality.
At one point in time (about 2008-2009) the email transport class I administered powered about 70% of all outbound emails worldwide. Today it's much less. Quite frankly, I don't ever want to reach that plateau ever again ... I would prefer PHPMailer Pro (and my other project, SMTPMailer) handled the needs of those looking for simplicity, ease of use.
What's the difference between PHPMailer Pro and SMTPMailer? Well, first of all, neither is looking to convert you from another package. If you are happy with what you are using, continue using it. Changing email transport means learning new coding standards and context – that can be a challenge. If you want a new email transport system, the first choice is SMTPMailer. It's designed as a "lite" version of PHPMailer Pro and does not support load balancing. By my guess-timate, I suspect it meets the needs of well over 75% of users that aren't pumping out volumes of emails or mailing-lists. That, of course, leaves PHPMailer Pro to handle everything from a single email to heavy-duty mailing tasks. Need to discuss? Send me an email.