phpemail

Add second email address to variable php


I am using a plugin (Easy Digital Downloads) that sends an email for pending purchases, I need to add a second static email address into this email either as direct or cc. How can I do this? This is the current code...

function eddcg_send_payment_instructions_email( $payment_id = 0 ) {

$email_body = edd_get_option( 'eddcg_pending_email' );

if ( empty ( $email_body ) ) {
    return;
}

$email_body = edd_do_email_tags( $email_body, $payment_id );

$subject = edd_do_email_tags( edd_get_option( 'eddcg_pending_email_subject' , __( 'Your purchase is pending payment', 'eddcg' ) ), $payment_id );

$user_info = edd_get_payment_meta_user_info( $payment_id );

EDD()->emails->heading = edd_do_email_tags( edd_get_option( 'eddcg_pending_email_heading', false ), $payment_id );

EDD()->emails->send( $user_info['email'],  $subject, $email_body );

}


Solution

  • EDD_Emails::send uses wp_mail.

    Codex says:

    $to

    (string or array) (required)

    The intended recipient(s). Multiple recipients may be specified using an array or a comma-separated string.

    So, these will work

    EDD()->emails->send( array( $user_info['email'], $second_user_info['email'] ),  $subject, $email_body );
    

    or

    EDD()->emails->send( $user_info['email'].','.$second_user_info['email'],  $subject, $email_body );