How to override the email function by using filters? [closed]

If Divi theme uses wp_mail() function (which most likely does), you can use the wp_mail filter to pass your own arguments to the function:

function filter_divi_mail( $args ) {
    // Modify the options here
    $custom_mail = array(
        'to'          => $args['to'],
        'subject'     => $args['subject'],
        'message'     => $args['message'],
        'headers'     => $args['headers'],
        'attachments' => $args['attachments'],
    );
    // Return the value to the original function to send the email
    return $custom_mail;
}
add_filter( 'wp_mail', 'filter_divi_mail' );

Leave a Comment