Skip to main content
AhaSend lets Laravel send transactional email through its SMTP mailer; this guide gives you a short sandbox test and a production configuration with required TLS. Before sending, verify your domain and create an SMTP credential. Use a sandbox credential for these examples so no email is delivered. Keep the username and password in your server’s secret store. Use PHP 8.2 or newer, Composer and a Laravel 12 application. In its private .env, set MAIL_USERNAME, MAIL_PASSWORD to sandbox SMTP credentials and MAIL_FROM_ADDRESS to your verified sender. Do not commit that file.

Install Laravel

In a new working directory, create a test app. For an existing Laravel 12 app, use its root directory instead.
Save quick-send.php in the app root:
quick-send.php
Run php quick-send.php. A transport failure throws an exception.

Configure Laravel’s SMTP Mailer

Replace the sample app’s config/mail.php with this file. In an existing app, merge the smtp mailer and sender settings with your current configuration.
config/mail.php
Laravel passes require_tls to Symfony’s SMTP transport. Keep TLS certificate checks enabled. Clear any old cached configuration with php artisan config:clear; rebuild the configuration cache in your normal deployment process after the secrets are present. See Laravel Mail for mailables and queues.

Add a Command with Failure Handling

Add this to routes/console.php, after its existing opening PHP tag. The following complete file also works in the sample app.
routes/console.php
Run php artisan mail:send-test recipient@example.com with a sandbox credential. In your app, choose the recipient from the authenticated user’s data and dispatch a job after its database transaction commits. Save the job outcome. SMTP does not have API idempotency keys, so reconcile an uncertain submission before retrying. Track delivery events separately from SMTP acceptance.