Before you start
Tick off what you already have. New to tinyRelay? See how onboarding works.
[SMTP host], [port] and [encryption]. Whether SMTP sends receive the same webhooks and metadata as API sends is being confirmed.Configure Laravel mail for the SMTP relay
Laravel reads mail settings from .env through config/mail.php. You change the environment, not your code.
1. Add the credentials to .env
Pick the tab that matches your config/mail.php. Current skeletons read MAIL_SCHEME; older ones read MAIL_ENCRYPTION.
MAIL_MAILER=smtp
# Issued at onboarding
MAIL_HOST="[SMTP host]"
MAIL_PORT="[port]"
# smtp = STARTTLS, smtps = implicit TLS: match the [encryption] you were given
MAIL_SCHEME="[smtp or smtps]"
MAIL_USERNAME="[SMTP username]"
MAIL_PASSWORD="[SMTP password]"
MAIL_FROM_ADDRESS="no-reply@acme.com"
MAIL_FROM_NAME="${APP_NAME}"MAIL_MAILER=smtp
# Issued at onboarding
MAIL_HOST="[SMTP host]"
MAIL_PORT="[port]"
MAIL_ENCRYPTION="[encryption]"
MAIL_USERNAME="[SMTP username]"
MAIL_PASSWORD="[SMTP password]"
MAIL_FROM_ADDRESS="no-reply@acme.com"
MAIL_FROM_NAME="${APP_NAME}"For MAIL_SCHEME: use smtp when the [encryption] you were given is STARTTLS, and smtps when it is implicit TLS.
2. Check config/mail.php
// config/mail.php (current skeleton: no edits needed)
'default' => env('MAIL_MAILER', 'log'),
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'scheme' => env('MAIL_SCHEME'),
'url' => env('MAIL_URL'),
'host' => env('MAIL_HOST', '127.0.0.1'),
'port' => env('MAIL_PORT', 2525),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
],
// ...
],
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Laravel')),
],// config/mail.php (older skeletons use an 'encryption' key; defaults omitted)
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST'),
'port' => env('MAIL_PORT'),
'encryption' => env('MAIL_ENCRYPTION'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
],
// ...
],3. Clear cached config
If you have run php artisan config:cache, Laravel ignores .env until you clear or rebuild the cache.
php artisan config:clear4. Send a test email
Send one message to an inbox you control before switching production traffic.
php artisan tinker
> Mail::raw('tinyRelay SMTP test', fn ($m) => $m->to('you@example.com')->subject('SMTP test'));Send Laravel mail through the SMTP relay
Nothing else changes. Mailables, notifications and queued mail all go through the default mailer.
use App\Mail\OrderShipped;
use Illuminate\Support\Facades\Mail;
// Send now
Mail::to($request->user())->send(new OrderShipped($order));
// Or queue it so the web request does not wait on SMTP
Mail::to($request->user())->queue(new OrderShipped($order));Keep the password out of version control
.env should not be committed. In production, set the same MAIL_* variables in your host's secret store. If you use the REST API from PHP as well, see send email with PHP.
Delivery events and the REST API
tinyRelay posts signed webhook events (SEND, DELIVERED, BOUNCED, OPEN, CLICK, UNSUBSCRIBE and SPAM) with your metadata on each one.
Whether SMTP sends receive the same webhooks and metadata is being confirmed, and this guide will be updated when it is.
If you need your own IDs echoed on every event today, send those messages through the API instead: see the transactional email API and email webhooks.
Troubleshooting
The username or password does not match what was issued at onboarding. Copy them again and check for stray quotes or spaces in your environment file.
Check [SMTP host] and [port]. Some hosting providers block outbound SMTP ports; ask yours if a correct host and port still time out.
The encryption mode does not match the port. STARTTLS and implicit TLS are different settings; use the [encryption] you were given.
Send from an address on a domain that was set up with tinyRelay during onboarding.
Check the DKIM CNAME on your sender domain, then the recipient address. The email bounce codes reference explains each bounce category.
FAQ
They are issued at onboarding together with your SMTP username and password, so they are shown here as placeholders. Use exactly the values you were given.
Check config/mail.php. If the smtp mailer has a scheme key, set MAIL_SCHEME to smtp for STARTTLS or smtps for implicit TLS. If it has an encryption key, set MAIL_ENCRYPTION.
Your configuration is probably cached. Run php artisan config:clear, or rebuild the cache with php artisan config:cache.
This is being confirmed. Email sent through the REST API gets signed webhook events with your metadata; this guide will be updated for SMTP.
Next steps
- SMTP relay service
- Send email with PHP over the REST API
- SMTP vs API
- Transactional email deliverability
- tinyRelay docs: setup