rubricate / mailer
Component for sending emails via authenticated SMTP. It works on remote servers with support for sockets (fsockopen) and TLS.
v1.0.0
2025-06-01 21:31 UTC
Requires
- php: >=7.2.0
README
Last Version
$ composer require rubricate/mailer
Documentation is at https://rubricate.github.io/components/mailer
Requirements
- PHP server with sockets and TLS/SSL support
Check if your PHP server supports sockets and TLS/SSL:
1. Sockets support in PHP
If sockets appears, support is enabled.
php -m | grep sockets
or code:
if (extension_loaded('sockets')) { echo "Sockets extension is enabled."; } else { echo "Sockets extension is NOT enabled."; }
2. TLS/SSL support (via OpenSSL)
TLS is supported via the openssl extension. This extension is used for secure connections (SMTP with TLS/SSL, HTTPS, etc.).
php -m | grep openssl
or via code:
if (extension_loaded('openssl')) { echo "OpenSSL is enabled (TLS/SSL support)"; } else { echo "OpenSSL is NOT enabled"; }
Usage example
$mailer = new SmtpMailer( 'smtp.gmail.com', // Host 587, // Port 'yourmail@gmail.com', // User 'your_password_or_appkey', // Password or App Password 'yourmail@gmail.com', // Sender 'Your Name', // Sender's Name true // Enable debugging ); try { $mailer->send( 'destination@example.com', // Recipient 'Pure SMTP email test', // Subject '<h1>Working!</h1><p>This is a test via Rubricate Mailer.</p>', // Body true // Send as HTML ); echo "Email sent successfully!"; } catch (Exception $e) { echo "Error sending: " . $e->getMessage(); }
Credits
- Estefanio N Santos (Developer)
- All Contributors (Let's program)
License
The MIT License (MIT). Please see License File for more information.