Viesti Sign in

Send WordPress email over SMTP

WordPress sends email with wp_mail(), which by default hands messages to PHP's mail(). Point it at Viesti over SMTP with the WP Mail SMTP plugin's Other SMTP mailer, or with a short phpmailer_init snippet if you prefer no plugin.

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

Option 1: WP Mail SMTP

Install and activate WP Mail SMTP from Plugins, then open WP Mail SMTP » Settings and fill in:

Field Value
From Email An address on your verified domain
Force From Email On, so other plugins cannot send from an unverified address
Mailer Other SMTP
SMTP Host smtp.viesti.email
Encryption TLS
SMTP Port 587
Authentication On
SMTP Username apikey
SMTP Password Your API key

In WP Mail SMTP, TLS means STARTTLS. The Auto TLS switch only matters when Encryption is None or SSL.

Keep the key out of the database

Settings entered in the admin are stored in the database and visible to every administrator. WP Mail SMTP also reads them from constants in wp-config.php, placed above the line /* That's all, stop editing! Happy publishing. */; fields set this way are shown grayed out.

define( 'WPMS_ON', true );
define( 'WPMS_MAILER', 'smtp' );
define( 'WPMS_SMTP_HOST', 'smtp.viesti.email' );
define( 'WPMS_SMTP_PORT', 587 );
define( 'WPMS_SSL', 'tls' );
define( 'WPMS_SMTP_AUTH', true );
define( 'WPMS_SMTP_AUTOTLS', true );
define( 'WPMS_SMTP_USER', 'apikey' );
define( 'WPMS_SMTP_PASS', getenv( 'VIESTI_API_KEY' ) );
define( 'WPMS_MAIL_FROM', getenv( 'MAIL_FROM' ) );
define( 'WPMS_MAIL_FROM_FORCE', true );

getenv() returns variables your server passes to PHP, for example env[VIESTI_API_KEY] lines in a PHP-FPM pool; MAIL_FROM is a bare address here. If your host cannot set environment variables, write the values in place of the getenv() calls; wp-config.php is not stored in the database.

Option 2: phpmailer_init, no plugin

Save this as wp-content/mu-plugins/viesti-smtp.php. WordPress loads must-use plugins automatically, without activation.

<?php
/**
 * Plugin Name: Viesti SMTP
 * Description: Sends wp_mail() through Viesti over SMTP with STARTTLS.
 */

add_action( 'phpmailer_init', function ( $phpmailer ) {
	$phpmailer->isSMTP();
	$phpmailer->Host       = 'smtp.viesti.email';
	$phpmailer->Port       = 587;
	$phpmailer->SMTPSecure = 'tls';
	$phpmailer->SMTPAuth   = true;
	$phpmailer->Username   = 'apikey';
	$phpmailer->Password   = getenv( 'VIESTI_API_KEY' );
	$phpmailer->Timeout    = 10;
} );

add_filter( 'wp_mail_from', function () {
	return getenv( 'MAIL_FROM' );
} );

SMTPSecure = 'tls' is STARTTLS in PHPMailer. Without the wp_mail_from filter, WordPress sends from wordpress@ followed by your site's host name without www., which works only if that domain is the one you verified.

Test it

With WP Mail SMTP, open WP Mail SMTP » Tools, Email Test tab. With either option, WP-CLI sends a message and prints the PHPMailer error if it fails:

wp eval 'add_action( "wp_mail_failed", function ( $e ) { echo "FAILED: ", $e->get_error_message(), "\n"; } ); var_dump( wp_mail( "[email protected]", "Your receipt", "Thanks for your order." ) );'

bool(true) means Viesti accepted the message; check Activity in the dashboard.

Port 465

In WP Mail SMTP choose Encryption SSL and SMTP Port 465 (constants: WPMS_SSL 'ssl', WPMS_SMTP_PORT 465). In the snippet set SMTPSecure = 'ssl' and Port = 465.

Common errors

Error Cause and fix
SMTP Error: Could not connect to SMTP host. Failed to connect to server Encryption SSL on port 587, or the host blocks outbound SMTP. Use TLS with 587, SSL with 465, or ask your host to open the port.
SMTP Error: Could not authenticate. The key is wrong, or Encryption is None with Auto TLS off, so the connection was never encrypted and Viesti did not offer authentication. Use Encryption TLS.
The send hangs for about five minutes, then fails with SMTP Error: Could not connect to SMTP host. Encryption TLS on port 465: PHPMailer waits for a plain-text greeting that only comes after TLS. Use SSL for 465.
SMTP Error: Data not accepted. Viesti refused the message, most often with 550 sending not permitted because the From address is not on your verified domain. Set From Email with Force From Email, or the wp_mail_from filter.
Invalid address: (From): The wp_mail_from filter returned nothing because MAIL_FROM is not visible to PHP.

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.

Plugin fields are from WP Mail SMTP's Other SMTP guide and constants guide, constant names from the plugin's source (version 4.9.0); hooks from the WordPress reference for phpmailer_init and wp_mail_from. Tested with WordPress 7.1.2. Checked 26 September 2026.