Viesti Sign in

Send email from Laravel over SMTP

Laravel sends mail through Symfony Mailer, configured from MAIL_* variables in .env. Since Laravel 11 the TLS mode is MAIL_SCHEME; MAIL_ENCRYPTION from older apps is no longer read.

Before you start

  1. Sign in and verify the domain you send from. Viesti accepts a message only when its From address is on a domain verified in your workspace and the envelope sender (MAIL FROM), which most libraries take from the From address, is on the same domain. DNS setup lists the records.
  2. Create an API key on the Credentials page of the dashboard. It is shown once. The key is the SMTP password; the username is apikey.
Setting Value
Host smtp.viesti.email
Port 587 with STARTTLS, or 465 with TLS from the first byte
Username apikey
Password Your API key: mr_ followed by 64 hex characters
Authentication PLAIN, offered only once the connection is encrypted

Configure .env

MAIL_MAILER=smtp
MAIL_SCHEME=smtp
MAIL_HOST=smtp.viesti.email
MAIL_PORT=587
MAIL_USERNAME=apikey
MAIL_PASSWORD=mr_your_api_key
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

MAIL_SCHEME=smtp connects in plain text and upgrades with STARTTLS, which Symfony Mailer does automatically when the server offers it, as Viesti does on 587. smtps means TLS from the first byte, for port 465. If MAIL_SCHEME is empty, Laravel picks smtps for port 465 and smtp for any other port.

Real environment variables take precedence over .env, so in production you can set MAIL_PASSWORD in the server environment and keep the key out of the file.

Send an email

use Illuminate\Support\Facades\Mail;

Mail::raw('Thanks for your order.', function ($message) {
    $message->to('[email protected]')->subject('Your receipt');
});

In an application you would usually send a Mailable class; the transport settings are the same.

Test it

Open php artisan tinker and paste the snippet above. It completes without an exception when Viesti accepts the message; check Activity in the dashboard.

Port 465

MAIL_SCHEME=smtps
MAIL_PORT=465

Common errors

Error Cause and fix
UnsupportedSchemeException: The "tls" scheme is not supported; supported schemes for mailer "smtp" are: "smtp", "smtps". An old MAIL_ENCRYPTION value was copied into MAIL_SCHEME. Use smtp for 587.
TransportException: Connection could not be established with host "ssl://smtp.viesti.email:587" … wrong version number MAIL_SCHEME=smtps on port 587. Use smtp for 587, smtps for 465.
TransportException: Connection to "smtp.viesti.email:465" timed out. MAIL_SCHEME=smtp on port 465. Use smtps, or leave MAIL_SCHEME empty.
UnexpectedResponseException: Expected response code "250" but got code "550", with message "550 5.0.0 sending not permitted". MAIL_FROM_ADDRESS is not on a domain verified in your workspace.
Changes to .env have no effect The configuration is cached; .env is not read once php artisan config:cache has run. Run php artisan config:clear, or re-cache after editing.

Replies from Viesti

Whatever the library, its error includes the server's reply. These are the ones caused by your setup or account:

Reply Meaning
535 5.7.8 Authentication failed The API key is wrong, revoked or empty. After ten failed attempts from one client address within ten minutes, that address is refused for ten minutes with 454 Too many failed authentications; retry later.
525 5.7.13 Workspace suspended; contact support The key is valid, but the workspace is suspended or under review. Write to [email protected]; a new key does not help.
550 5.0.0 sending not permitted The From domain is not verified in this workspace, the envelope sender is on a different domain than the From header, or the workspace is not active.
550 5.0.0 recipient suppressed The recipient is on your suppression list after a bounce or complaint; see Bounces.
451 4.0.0 submission quota exceeded The free plan's 75 emails per UTC day or 2,000 per UTC month are used up; see Limits. It is temporary: retry after the reset or upgrade.
452 4.5.3 Maximum limit of 50 recipients reached One message can have at most 50 recipients. Split the send.
552 5.0.0 message too large The message, attachments included, is over 10 MB.
554 5.0.0 rejected by content audit Content screening found the message in violation of the Terms of Service. It is not relayed.

A 250 reply means Viesti accepted the message. Content screening runs before relay; mail it flags is held for review and shows as quarantined on the Activity page.

Next steps

  • DNS setup: DKIM, SPF, DMARC and return-path records for your domain.
  • SMTP reference: ports, TLS and authentication in detail.
  • HTTP API: send the same message as JSON over HTTPS.
  • Limits and Bounces: quotas, message size and suppressions.

Variable names are from the Laravel application skeleton's config/mail.php and the scheme choice from the framework's MailManager; configuration caching from the Laravel 13 configuration docs. Tested with Laravel 13.33 on PHP 8.5. Checked 26 September 2026.