gravitysmtp_connector_for_sending

Description

This gravitysmtp_connector_for_sending filter lets you dynamically choose which SMTP connector should handle a specific email. You can select a connector by slug, abort the send, or force a specific connector while skipping retry and backup logic.

Usage

add_filter( 'gravitysmtp_connector_for_sending', 'your_function_name', 10, 3 );

Parameters

ParameterTypeDescription
$current_typestringThe current connector type is being returned. Refer to Gravity SMTP Integration Slugs article for more information.
$email_dataarrayAn array of all the email data being used for this call.
$sourcestringThe source of the email.

Examples

Force a specific connector for certain emails and log the source.

add_filter( 'gravitysmtp_connector_for_sending', function( $current, $email_data, $source = '' ) {
    error_log( 'GSMTP source: ' . var_export( $source, true ) );
    return $current;
}, 10, 3 );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Since

This filter was added in Gravity SMTP version 1.2.

Source Code

This filter is located in includes/handler/class-mail-handler.php