I have a form that uses code within functions.php that takes emails as an array from an ACF field and assigns it to the mail properties’ additional_headers key. It also changes the recipient to that of another ACF field.
$cc_users = $cc ? 'Cc: ' . implode(', ', $cc) : '';
$contact_form->set_properties( array(
'mail' => array(
'recipient' => $recipient_email,
'additional_headers' => $cc_users,
'subject' => $contact_form->prop('mail')['subject'],
'body' => $contact_form->prop('mail')['body'],
),
) );
This code currently works as expected.
I however, I would like to add Reply-To to this form so that users click reply and have it go to to the submitter.
How can I modify this code? Adding this to the code does not work
$reply_to_user = $posted_data['Email'];
$reply_to = ' Reply-To: ' . $reply_to_user;
$cc_users = $cc ? 'Cc: ' . implode(', ', $cc) : '';
$contact_form->set_properties( array(
'mail' => array(
'recipient' => $recipient_email,
'additional_headers' => $reply_to . $cc_users,
'subject' => $contact_form->prop('mail')['subject'],
'body' => $contact_form->prop('mail')['body'],
),
) );
I can see that the $reply_to variable is be populated correctly. But when I try to submit a form it errors out. Logs show that it thinks the cc email is part of the Reply-To address.
E.g. “Reply-To:” “[email protected] Cc: [email protected]”
How can I escape the Reply-To correctly so that the CC can proceed?