I am able to send the email with no issues, but the email is not being CC'd even after I am inputting this in the headers argument. Am I missing something in my code below?
$to = 'myemail@example.com';
$subject = 'This email came from the site!';
$headers = array(
'Content-type: text/html',
'Cc: otheremail@example.com',
);
$body = $_POST['message'];
$response = wp_mail( $to, $subject, $body, $headers );
So the issue is that I needed to add the cc email in my array in this format
Alias Name <otheremail@example.com>
instead of just the email
otheremail@example.com
.
Now, the email is being cc'd properly.
Complete working sample.
$to = 'myemail@example.com';
$subject = 'This email came from the site!';
$headers = array(
'Content-type: text/html',
'Cc: Alias Name <otheremail@example.com>',
);
$body = $_POST['message'];
$response = wp_mail( $to, $subject, $body, $headers );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.