Benjoe
Benjoe

Reputation: 466

Calling wp_mail() twice in same function (the second one will not be sent)

I'm calling wp_mail() function twice in same function but the other one (second one) is not sending. Am I missing something?

function v_send_mail() {
    wp_mail( "[email protected]", $subject, $msg, $headers );
    wp_mail( "[email protected]", $subject, $msg, $headers );
}

echo v_send_mail();

If I reverse their positioning, the first email will not receive the email. Any solutions?

Upvotes: 0

Views: 599

Answers (1)

Vel
Vel

Reputation: 9257

Try this code.

function v_send_mail() {
    $group_emails = array("[email protected]", "[email protected]" );
    wp_mail($group_emails, 'my subject', 'my message', $headers);
}

if(v_send_mail()){
    echo "mail sent";
}

Upvotes: 2

Related Questions