get( 'mail', 'mailer' ); if ( ! $force && $current_mailer !== '' && $current_mailer !== 'mail' ) { WP_CLI::error( sprintf( /* translators: %s is the currently configured mailer slug (e.g. smtp, sendgrid). The slug is not translated. */ __( "WP Mail SMTP is already configured (mailer: %s).\nUse `wp wp-mail-smtp option set . ` to change individual settings, or pass --force to override this check.", 'wp-mail-smtp' ), $current_mailer ) ); } $resolved = $writer->resolve( $assoc_args ); if ( empty( $resolved ) ) { WP_CLI::error( __( 'No configuration flags provided. Pass at least --mail.from_email, --mail.from_name, and --mail.mailer (plus the credentials for that mailer).', 'wp-mail-smtp' ) ); } $writer->validate( $resolved ); $result = $writer->write( $resolved ); // Nothing stored means every flag was shadowed by a wp-config constant. if ( empty( $result['written'] ) ) { WP_CLI::error( __( 'No settings were stored — every flag passed was shadowed by a wp-config constant. Remove the constants and re-run, or pass flags for non-shadowed settings.', 'wp-mail-smtp' ) ); } // Skip the admin Setup Wizard redirect, mirroring wizard completion. update_option( 'wp_mail_smtp_activation_prevent_redirect', true ); $mailer = $resolved['mail.mailer'] ?? Options::init()->get( 'mail', 'mailer' ); WP_CLI::success( sprintf( /* translators: %s is the configured mailer slug (e.g. smtp, sendgrid). The slug is not translated. */ __( 'Configured WP Mail SMTP (mailer: %s). Run `wp wp-mail-smtp test ` to verify.', 'wp-mail-smtp' ), $mailer ) ); } }