• Resolved gbotica

    (@gbotica)


    Hi,

    Is there some way to have a BCC copy of all emails sent via Offload SES to another email address?

    In the docs I see there is a hook “wposes_mail_sent” which could be used for posting to a logging app or maybe Slack API or similar. I’m guessing that using this hook to send another email would be a bad idea… would create an infinite loop…

    function myMailSentHook( $to, $subject, $message, $headers, $attachments ) {
        // Your code here.
    }
    add_action( 'wposes_mail_sent', 'myMailSentHook', 10, 5 );

    So, that’s not much use.

    In the changelog (https://github.com/deliciousbrains/wp-offload-ses-lite)I see:

    = 0.4.8 =
    * Experimental support for cc: and Bcc: in custom header
    * Domain verification is ok

    But I can’t find any other mention of it… how do I add a BCC to a custom header?

    Any help or guidance appreciated.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Delicious Brains

    (@deliciousbrains)

    WP Offload SES makes sure to run the usual wp_mail filter to let other plugins twiddle the parameters.

    So you can add a filter like the following to your child theme’s functions.php file:

    function add_bcc_to_wp_mail( $mail ) {
        $headers = array();
        if ( isset( $mail['headers'] ) ) {
            if ( is_array( $mail['headers'] ) ) {
                $headers = $mail['headers'];
            } else {
                $headers = explode( "\n", str_replace( "\r\n", "\n", $mail['headers'] ) );
            }
        }
    
        $headers[] = 'Bcc: [email protected]'; // TODO: CHANGE!
        $mail['headers'] = $headers;
    
        return $mail;
    }
    add_filter( 'wp_mail', 'add_bcc_to_wp_mail' );

    This is a very simple version, you may want to make it a bit more robust if there’s a chance that a BCC header has already been set.

    -IJ

    Thread Starter gbotica

    (@gbotica)

    That’s great — thanks very much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How can I add a BCC to all emails sent via WP Offload SES?’ is closed to new replies.