A custom Laravel mail driver for NewsMAN via the SMTP API (message.send_raw
endpoint).
This driver sends the full MIME message generated by Laravel/Symfony (headers, HTML/text parts, attachments, inline images) without extra transformations.
Vendor:
newsman
• Package:laravel-newsman-smtp
- Custom Symfony Mailer transport:
newsman
- Interactive setup (no need to edit
.env
) - Global
from_address
/from_name
configuration - Dedicated logging channel with request/response and sensitive data redacted
- Artisan commands for setup, testing, and uninstall
- Auto-injects into
config('mail.mailers')
(no manual config edits)
- PHP 8.1+
- Laravel 10.x / 11.x
- Typical PHP extensions (mbstring, json, etc.)
composer require newsman/laravel-newsman-smtp
Run interactive setup (stores credentials in storage/app/newsman/credentials.php
and sets from_*
):
php artisan newsman:setup
# Prompts: Account ID, API Key, From address, From name
Clear caches (the setup command already does this, but you can run manually if needed):
php artisan config:clear
php artisan cache:clear
php artisan newsman:test [email protected]
Mail::mailer('newsman')->html('<h1>Hello</h1><p>This is HTML!</p>', function ($m) {
$m->to('[email protected]')->subject('HTML test');
});
use Illuminate\Mail\Mailable;
use Symfony\Component\Mime\Email;
class InvoiceMail extends Mailable
{
public function build()
{
return $this->subject('Your Invoice')
->view('emails.invoice') // HTML view
->text('emails.invoice_plain') // Plain text view
->attach(storage_path('app/invoices/123.pdf'), [
'as' => 'Invoice-123.pdf', 'mime' => 'application/pdf'
])
->withSymfonyMessage(function (Email $email) {
$email->getHeaders()->addTextHeader('X-Track', 'invoice-123');
$email->embedFromPath(public_path('logo.png'), 'logo_cid', 'image/png');
});
}
}
In HTML view:
<img src="cid:logo_cid" alt="Logo" />
The driver sends the raw MIME to NewsMAN (
mime_message
), so HTML, text, attachments, and inline images are preserved.
-
Interactive setup (API key, Account ID, From info):
php artisan newsman:setup # Non-interactive options: # --account-id=... --api-key=... --from-address=... --from-name=... --endpoint=...
-
Send test email:
php artisan newsman:test [email protected] --subject="NewsMAN Test"
-
Uninstall (reset to smtp, clear storage and caches):
php artisan newsman:uninstall # Keep credentials if you plan to reinstall later: php artisan newsman:uninstall --keep
The package adds a dedicated log channel: storage/logs/newsman.log
.
- Logs request (endpoint, subject, recipients) and response (status, headers, body/json).
- Sensitive fields (
api_key
,mime_message
) are REDACTED.
Config (config/newsman.php
):
'log' => [
'enabled' => true,
'channel' => 'newsman',
'level' => 'info',
'redact' => ['api_key','mime_message'],
'requests' => true,
'responses' => true,
],
'http' => [
'timeout' => 15,
'retry' => ['times' => 2, 'sleep' => 200], // ms
'debug' => false, // if true → Guzzle debug logged to laravel.log
],
View logs:
tail -f storage/logs/newsman.log
After modifying credentials, endpoint, or logging:
php artisan config:clear
php artisan cache:clear
composer dump-autoload
Mailer [newsman] is not defined
- Ensure the package is installed and provider registers:
MailManager::extend('newsman', ...)
config('mail.mailers.newsman')
inboot()
- Run:
php artisan config:clear && php artisan cache:clear
- Check in Tinker:
→ should include
config('mail.mailers')
newsman
.
From defaults to [email protected]
- Verify
storage/app/newsman/credentials.php
hasfrom_address
/from_name
. - In Tinker:
config('newsman.from_address') config('mail.from')
Error AbstractTransport::$dispatcher must not be accessed before initialization
- Ensure your
NewsmanTransport
constructor calls:parent::__construct($dispatcher, $logger);
Minimum-stability / cannot find version
- Install with
dev-main
or tag a version (v1.0.0
) and require with^1.0
.
-
Reset to Laravel’s default mailer (
smtp
):php artisan newsman:uninstall
-
Remove the package:
composer remove newsman/laravel-newsman-smtp