Skip to content

Fortified IDDocs

SMTP

Module for outbound SMTP messages

Platform module for application outbound SMTP requests.

Multiple instances of the module can be configured to support outbound request with different properties, like timeouts, proxies or SSL/TLS settings.

Callers targets the requested instance by its name which must be configuration unique.

Messages can be sent in plain text or HTML format.

NameDescriptionDefault valueMandatory
nameDestination name. Unique identifier for a specific configuration/connection/service. This value must be unique for all smtpclient configurations."default"
hostSMTP server host.N/A
portSMTP server port.N/A
fromWho is the message from."[email protected]"
user_nameUser name when identifying against SMTP server.N/A
passwordUsed when authenticating against SMTP server.N/A
start_tlsDefines if communications must use TLS. Allowed values are : "OPTIONAL", "DISABLED" or "REQUIRED""OPTIONAL"
keep_aliveShould a pool be used keeping connections open.true
reconnect_intervalvalue for reconnect interval in ms.1000
keep_alive_timeoutThis value determines how long a connection remains unused, in seconds, in the pool before being evicted and closed.600
connect_timeoutHow many milliseconds before a connect attempt fails.5000
disable_esmtpset if ESMTP should be tried as first command (EHLO), rfc 1896true
idle_timeoutTimeout in seconds.600
loginpossible options for a login into a SMTP server either "DISABLED", "NONE", "REQUIRED" or "XOAUTH2""NONE"
reconnect_attemptsNumber of reconnect attempts.3
use_alpnWhether to use or not Application-Layer Protocol Negotiation.false
ssl_trust_allIgnore SSL validation.false
ssl_handshake_timeoutthe SSL handshake timeout in ms.10
use_sslis SSL/TLS enabled.false
proxy_hostHost for proxying.N/A
proxy_portPort for proxying.N/A
proxy_typeProxy protocol supported by Vert.x, for example HTTP or SOCKS5."HTTP"
proxy_userN/A
proxy_passwordN/A
auth_methodsAuthentication methods supported by the SMTP server. The following are supported: "XOAUTH2, DIGEST-MD5, CRAM-SHA256, CRAM-SHA1, CRAM-MD5, PLAIN, LOGIN". Use "" if you are unsure of which auth methods are supported."DIGEST-MD5, CRAM-SHA256, CRAM-SHA1, CRAM-MD5, PLAIN, LOGIN"
slow_mail_warning_msLogs a warning if SMTP send is still in progress after this many milliseconds. 0 or lower disables the warning timer.5000
send_timeout_msLocal timeout for the entire SMTP request, including attachment preparation. 0 means disabled0
log_activityEnables "low-level" mail activity logging.false

OAuth 2.0 allows an SMTP client to authenticate by using a short-lived access token instead of a static password. In practice, the client first obtains a token from an identity provider, such as Microsoft Entra ID, and then uses that token with the SMTP server, typically through XOAUTH2. This improves security by reducing reliance on long-lived credentials and allowing authentication to be controlled through modern identity and access policies.

disable_esmtp and keep_alive must be false.

If auth_methods is set, its only value must be XOAUTH2. When omitted, the module selects XOAUTH2 automatically.

If login is set, it must allow SMTP authentication. When omitted, the module selects XOAUTH2 automatically.

password must not be set.

A separate oauth2 configuration block must be added.

NameDescriptionDefault valueMandatory
http_destinationName of the HttpClient module that should be used to fetch the token.
token_urlFull token endpoint URL, for example an Entra token endpoint.
token_parametersKey/value parameters sent in the token request body. Typical examples: grant_type, client_id, client_secret, scope.
token_headersExtra HTTP headers to include in the token request.
access_token_fieldName of the field in the token response that contains the access token."access_token"
expires_in_fieldName of the field in the token response that contains token lifetime in seconds."expires_in"
expires_at_fieldName of the field in the token response that contains an absolute expiry timestamp (epoch seconds). If configured and present, it takes precedence over expires_in_field.
refresh_skew_secondsSafety margin before expiry. The token will be refreshed before its actual expiry time.60
http_timeout_msTimeout for the token HTTP request.5000

To enable more information in logs use these loggers in the log4j2.xml file:

<AsyncLogger name="foss.platform.modules.smtp.SmtpRequestHandler" level="TRACE"/>

or for a broader scope use:

<AsyncLogger name="foss.platform.modules.smtp" level="TRACE"/>

For low-level logging with log_activity set to true, use this logger:

<AsyncLogger name="io.vertx.ext.mail.impl.SMTPConnection" level="TRACE"/>

Required level by message type:

  • DEBUG
    • request received
    • request prepared
    • attachment preparation
    • attachment file read
    • SMTP send start
  • INFO
    • SMTP send success
  • WARN
    • slow send warning from slow_mail_warning_ms
    • late SMTP success ignored after timeout
    • late SMTP failure ignored after timeout
  • ERROR
    • local SMTP timeout
    • SMTP send failure
    • request preparation failure
  • TRACE
    • full Vert.x mail response payload

Practical guidance:

  • use DEBUG for normal SMTP troubleshooting
  • use WARN if the focus is only slow/hanging mail behavior
  • use TRACE if response payload details are needed

This module produces metrics for each request.

namefortified.internal.smtpclient_<metric-name>
tagsname=<instance-name>

When sending e-mail using following events are possible

  • SMTP001 - Mail sent
    • traceID if present
    • to - comma separated list
    • cc - comma separated list
    • bcc - comma separated list
    • subject - message subject
  • SMTP002 - Mail could not be sent
    • traceID if present
    • subject - message subject
  • SMTP003 - Mail send timed out
    • traceID if present
    • subject - message subject
    • Note: local timeout in SMTP module; final delivery outcome may still be unknown.