Overview of the Issue
When you use WPML with WP Mail SMTP (opens in a new tab), you cannot translate the From Name of the emails. Emails in secondary languages are sent with the From Name of the default language.
Workaround
Please, make sure of having a full site backup of your site before proceeding.
- Go to WP Mail SMTPSettings and turn on Force From Name.
- Go to WPMLSettingsCustom XML Configuration and add:
<wpml-config> <admin-texts> <key name="wp_mail_smtp"> <key name="mail"> <key name="from_name"/> </key> </key> </admin-texts> </wpml-config> - Add this code to your theme’s functions.php file:
add_filter( 'wp_mail_smtp_options_get', function ( $value, $group, $key ) { if ( 'mail' === $group && 'from_name' === $key && is_string( $value ) ) { $value = apply_filters( 'wpml_translate_single_string', $value, 'admin_texts_wp_mail_smtp', '[wp_mail_smtp][mail]from_name' ); } return $value; }, 10, 3 ); - Go to WPMLString Translation and translate the From Name.