.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.quick-send.php in the app root:
quick-send.php
php quick-send.php. A transport failure throws an exception.
Configure Laravel’s SMTP Mailer
Replace the sample app’sconfig/mail.php with this file. In an existing app, merge the smtp mailer and sender settings with your current configuration.
config/mail.php
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 toroutes/console.php, after its existing opening PHP tag. The following complete file also works in the sample app.
routes/console.php
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.
Related Guides
- Before sending: verify your domain and create an SMTP credential.
- Connection and message rules: SMTP hosts, ports and limits, special headers, sandbox mode, retention and plan features.
- Other ways to send: REST API, AhaSend CLI, Node.js SDK and Go SDK.
- Delivery events: webhook setup and local webhook testing.

