Download the PHP package websitesql/mailer without Composer
On this page you can find all versions of the php package websitesql/mailer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download websitesql/mailer
More information about websitesql/mailer
Files in websitesql/mailer
Package mailer
Short Description A simple PHP framework for sending emails with PHPMailer and Plates.
License MIT
Homepage https://www.websitesql.com
Informations about the package mailer
WebsiteSQL Mail
A fluent, chainable PHP email library supporting multiple mail drivers (PHP mail, SMTP, log) with HTML/plain text content and template support using League/Plates.
Installation
Configuration
The MailProvider class requires an array of configuration options:
Basic Usage
The library uses a fluent interface with method chaining:
API Reference
Constructor
Creates a new instance of the MailProvider class.
Parameters:
$options(array): Configuration options for the mail provider
Methods
template(string $template, array $data = []): self
Sets the email content using a template.
Parameters:
$template(string): Template name (without file extension)$data(array): Data to pass to the template
Returns: Self (for method chaining)
Throws: RuntimeException if template path is not configured or template rendering fails
html(string $html): self
Sets the HTML content of the email.
Parameters:
$html(string): HTML content
Returns: Self (for method chaining)
plain(string $text): self
Sets the plain text content of the email.
Parameters:
$text(string): Plain text content
Returns: Self (for method chaining)
subject(string $subject): self
Sets the subject of the email.
Parameters:
$subject(string): Email subject
Returns: Self (for method chaining)
send(string $to): bool
Sends the email to the specified recipient.
Parameters:
$to(string): Email recipient
Returns: Boolean indicating success or failure
Throws: RuntimeException if required fields are not set
Email Drivers
PHP mail()
Uses PHP's built-in mail() function to send emails. Configure with:
SMTP
Uses PHPMailer to send emails via SMTP. Configure with:
Port 465 uses implicit SSL/TLS encryption, while port 587 uses STARTTLS.
Log
Logs emails to the error log instead of sending them. Useful for development and testing. Configure with:
Templates
The library uses League/Plates for templating. Create templates in your template directory:
Then use them:
Exception Handling
The library throws RuntimeException for configuration errors and other issues: