A lightweight, dependency-free completely self contained PHP SMTP mail sender that allows you to send emails without requiring any external libraries or Composer. Perfect for simple PHP projects that need email functionality without the overhead of large email libraries.
- No external dependencies required
- Supports both plain text and HTML emails
- Annex Files and Documents
- TLS encryption support
- SMTP authentication
- UTF-8 character encoding
- Optional debug mode
- Multiple recipient support
- Lightweight and easy to integrate
- Import and use in your project:
require_once 'smtpmail.php';
$mailer = new SMTPMail();
$mailer->createSimpleLetter('Subject', 'Email body', 'html');
$mailer->setRecipient('recipient@example.com', 'Recipient Name');
$mailer->sendLetter();
- Configure your SMTP settings in
config.php
:
define('SMTP_EMAIL', 'your-email@gmail.com');
define('SMTP_PASSWORD', 'your-app-specific-password');
define('SMTP_NAME', 'Your Name');
The script is pre-configured for Gmail SMTP but can be customized for any SMTP server:
- Default SMTP Host: smtp.gmail.com
- Default Port: 587
- Authentication: Required
- Security: TLS
- PHP 5.6 or higher
- OpenSSL extension enabled
- SMTP server access
MIT License - See LICENSE file for details
João Vieira mail@joaovieira.eu
Contributions are welcome! Please feel free to submit a Pull Request.