This is a lightweight SMTP PHPMailer.
Updated to work with PHP 8.0.
The PHP Class supports TLS, SSL and File Attachments in mail.
Simple, powerful and easy to use.
- Sends mail using one SMTP Server like 'smtp.gmail.com'.
- Auth login with username and password.
- Uses security protocols TLS and SSL.
- Supports 'text/html' or 'text/plain' messages.
- Supports any number of file attachments.
- Default Charset is 'UTF-8' but can be changed.
- 8bit, 7bit, Binary or Quoted-Printable transfer encoding.
- Logging of the transaction for debug.
- From - one address
- Reply-To - multiple possible
- To - multiple possible
- Cc - multiple possible
- Bcc - multiple possible
Set your config variables in your calling script.
Here's a basic example:
<?php
require '/path/to/SMTPMailer.php';
$mail = new SMTPMailer;
$mail->SMTPHost = 'mail.server.com';
$mail->Username = '[email protected]';
$mail->Password = 'password';
$mail->setFrom('[email protected]');
$mail->addAddress('[email protected]');
$mail->Subject = 'Greetings';
$mail->bodyPlain = <<<"PLAIN"
Hello! This is a test.
PLAIN;
$mail->bodyHTML = <<<"HTML"
This is a test from {$mail->SMTPHost} on port {$mail->Port}
<br>
<b>Greetings!</b>
HTML;
echo PHP_EOL;
if ($mail->Send()) { echo 'Mail was sent successfully!'. PHP_EOL; }
else { echo 'Mail failure!!!'. PHP_EOL; }
?>