PHPMailer2 and SMTPMailer

by Andy Prevost

Sunday December 10 2023

I fell ill in 2011/2012. Another developer took over the PHPMailer project and I am quite thankful for that assistance. PHP is not very friendly to email transportation and we all need email transportation software to help.

Most websites are hosted on a server where Sendmail (or Qmail) is the default for email transportation. Sendmail tends to get used for smaller tasks. SMTP is usually on the same server and is used for more robust tasks like sending emails from databases, mailing lists, or emails that include embedded graphics and all types of attachments.

The programming language PHP has a Mail() function that is a wrapper for Sendmail. If all you need is to get a basic text email out, Mail() can handle that reasonably. Any other tasks, and PHP's Mail() function becomes a nightmare. There are all kinds of PHP scripts to overcome this ... all using Mail() as the transport. That includes some of the most popular email transport classes (including PHPMailer). That came about because using Sendmail was a bit flaky ... that was a timing thing, where Sendmail was not installed on all servers. There were other Mail Transport Agents (MTA) choices like Qmail, etc. It is easier today because all of them are compatible.

My original project, PHPMailer, has become unwieldy. It's bloated, includes - in my opinion - useless code. Some of the original code from PHP version 3 that was created to work around the limitations of PHP language (at that time) are still in the core. Since turning over the project, the new administrators have included third-party code without first testing (then withdrew when users complained). Support is horrid with feedback to users blaming them for the errs in the software.

I've decided on a new course and have since launched PHPMailer2 and SMTPMailer.

PHPMailer2 follows on the path I was on in 2012. Keep it small, keep it unobtrusive, and keep it simple to use. It has all the great features that made my software popular. Like load balancing, sending individual emails, and is fast.

The last version of PHPMailer that I authored had a reasonably small footprint. The PHPMailer class was 73Kb, the SMTP class was 26Kb and the POP3 class was 11Kb. That's a total of 110Kb. 

A recent version of PHPMailer (6.5.3) had a total footprint of 237Kb ... with the PHPMailer class along taking up 172Kb. It's not any easier to use. The direction seems to be to support big mailing list providers and less so on the needs of the average user. The aim is to have users use composer to use the software, no instructions for other techniques.

PHPMailer2 is now available on Sourceforge. It's production ready at version 1.0.0 and comes in less than 80Kb ... with SMTP built-in. I'm currently working on the next release, and it's also under 80Kb. PHPMailer2 has all the same features, same functionality, same load balancing, same support for all types of attachments. It's not quite code compatible with PHPMailer, but I have a compatibility add-on class anyone can use.

One of the projects I created back around 2009 was a "lite" version of PHPMailer. That is no longer available, but I do have another project that is even smaller in size and easier to use. SMTPMailer comes in at under 50Kb and is also available on Sourceforge - and also production ready. Since it is as full featured and robust as PHPMailer2, I will be focusing a lot of my time and efforts on this package.

One other package deserves mention: PHPMailer-FE (FE = Form to Email) ... the admin that took over PHPMailer hacked into my Sourceforge account while I was ill and removed all of my Open Source projects. First, that was nasty – you have to be a real ass-hat to do that. Second, PHPMailer-FE was recommended by many hosting providers as a secure way of dealing with form input on websites. I have revived that project and renamed it as Form2Mail. It's essentially an updated package based on procedural functions. It now requires a minimum of PHP version 7.4 and does support the latest versions of PHP.

I am currently working on a brand new version of Form2Mail ... and I'm not sure whether to rename it or not. The new version will be a PHP class based project with at least three possible plug-ins, all post process. Post process just means that the plug-ins will work after the fields have been validated, cleaned up, verified to have all required fields and no malicious user input (like exploit paths, etc). The form user data will be available to the plug-in for further processing. The three plug-in points will be:

  • Prior to sending emails ... an example of use would be to verify that the user has not previously requested removal from receiving emails (ie, prevents malicious use of someone else's email address)
  • Prior to sending emails, as an autoresponder. Prevents the sending of an email to any recipients and hands over the further processing to the auto-responder plug-in. 
  • After sending emails ... an example would be to update a database of sent emails.

 

 

 

◀ Previous Next ▶

Post a Comment