On form submission how to send 2 email to different users

OK, so all you need to do is to add code for second email in the same place:

if ( isset( $_POST['submit']) ) {
    $ch_name = $_POST['ch_f_name'];
    $ch_phone_num = $_POST['ch_phone_num'];
    $ch_email = $_POST['ch_email'];
    $ch_company = $_POST['ch_company'];
    $ch_job_title = $_POST['ch_job_title'];
    $to = $ch_email;
    $subject = "Thank you for job Submission ";
    $content = "'.$ch_name.'";

    $headers="MIME-Version: 1.0" . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: Job Post at [email protected]' . "\r\n";
    wp_mail( $to, $subject, $content, $headers );

    // And here goes second email:
    $admin_email = get_option( 'admin_email' );
    $headers="From: Job Post at [email protected]" . "\r\n";
    wp_mail(
        $admin_email,
        'Subject of second email',
        'Message content',
        $headers
    );
}

Leave a Comment

tech