Modernising a Legacy PHP Invoicing System
Published Sep 24, 2025
A B2B invoice company needed to update an outdated PHP email system that they relied on to send invoices to clients.

The Challenge
A B2B invoice company needed to update an outdated PHP email system that they relied on to send invoices to clients:
- The system hadn’t been updated in 5+ years, causing timeouts after just 10 emails.
- Staff had to manually monitor and restart the app, wasting time and creating reliability risks.
- Security practices (credential storage, password handling) were outdated and unsafe.
The Solution
I helped upgrade and improve their existing system:
- Implemented version control for structured updates and collaboration allowing more control of code changes.
- Rewrote credential storage with modern encryption and environment variables.
- Introduced logging, wait times, and multiple SMTP/API provider support.
- Built a new process to send emails via command-line PHP, avoiding timeouts.
- Added safeguards:
- Stop after multiple failures
- Prevent duplicate sends
- Graceful shutdowns.
- Added email sending customisation (from different accounts and subject lines)
- Updated SPF and DMARC to improve email deliverability.
The Impact
- Faster, automated invoice emails without staff intervention.
- More secure system with modern encryption and proper credential management.
- Seamless compatibility with the company’s existing PHP systems.
- Emails no longer landed in junk/spam folders.
- Staff saved significant time - no more manual refreshing or monitoring.
- A reliable system that “just works” in the background.
Technical Details
- Upgraded to PHP 8.4 and latest PHPMailer.
- Integrated environment variable management for secure configuration.
- Database restructured for safer password storage (salted/encrypted).
- Added robust logging and debugging - allowing to diagnose problems easier with a button press
- Optimised to avoid PHP execution timeouts with external command-level processes.
- Added ability to store/send from multiple bulk email sending services (SES, SendGrid, Brevo etc.)