InitPHP Mailer composes an e-mail message through a fluent API and hands it to a
transport — PHP's native mail(), a local sendmail binary, or SMTP. It builds
MIME multipart bodies, encodes headers per RFC 2047, encodes bodies as
quoted-printable, and attaches files or inline images.
| Guide | What it covers |
|---|---|
| Getting started | Install, build your first message, send it. |
| Configuration | Every configuration key and its default. |
| Sending mail | Recipients, CC/BCC, BCC batching, HTML and alternatives. |
| Attachments | Files, in-memory content and inline (CID) images. |
| SMTP transport | Host, port, encryption, authentication, keep-alive, DSN. |
| Encoding & headers | Charset, Q-encoding, quoted-printable, word wrap, custom headers. |
| Exceptions | What is thrown, when, and how to catch it. |
| Facade | The static facade over a shared instance. |
use InitPHP\Mailer\Mailer;
use InitPHP\Mailer\Exception\MailerException;
$mailer = Mailer::newInstance([
'protocol' => 'smtp',
'SMTPHost' => 'smtp.example.com',
'SMTPUser' => 'you@example.com',
'SMTPPass' => 'secret',
'SMTPPort' => 587,
'SMTPCrypto' => 'tls',
]);
try {
$mailer->setFrom('you@example.com', 'Your Name')
->setTo('recipient@example.com')
->setSubject('Hello')
->setMessage('Plain-text body')
->send();
} catch (MailerException $e) {
// handle failure
}Mailer— the object you build a message on and callsend()against. Create it withMailer::newInstance($config)ornew Mailer($config).- Configuration — an array passed once at construction. It selects the transport and its options and provides message defaults (charset, priority…).
- Transport — the delivery backend chosen by the
protocoloption:mail,sendmailorsmtp. You never construct it directly. - Exceptions — failures throw; there are no boolean return values to check.
- PHP 8.1 or newer
ext-mbstring,ext-iconv,ext-fileinfo