I have a bit of php code that sends an email. I would like to add another email recipient to this code, so that the email is sent to BOTH the post author AND the following email address...
[email protected]
Yes, this is part of a Wordpress plugin. It's a small part of a large plugin that I have a LOT of time investing in setting up, so I can't just look for an alternate plugin. I really need to get this one to work.
Thanks in advance for any and all help with this. Here is the existing code:
<?php
if (get_post_meta( $post->ID, '_listing_contact_form', true) != '') {
echo do_shortcode(get_post_meta( $post->ID, '_listing_contact_form', true) );
} else {
$nameError = '';
$emailError = '';
if(isset($_POST['submitted'])) {
$url = get_permalink();
$listing = get_the_title();
if(trim($_POST['contactName']) === '') {
$nameError = 'Please enter your name.';
$hasError = true;
} else {
$name = trim($_POST['contactName']);
}
if(trim($_POST['email']) === '') {
$emailError = 'Please enter your email address.';
$hasError = true;
} else if (!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", trim($_POST['email']))) {
$emailError = 'You entered an invalid email address.';
$hasError = true;
} else {
$email = trim($_POST['email']);
}
$phone = trim($_POST['phone']);
if(function_exists('stripslashes')) {
$comments = stripslashes(trim($_POST['comments']));
} else {
$comments = trim($_POST['comments']);
}
if(!isset($hasError)) {
$emailTo = get_the_author_meta( 'user_email', $post->post_author );
if (!isset($emailTo) || ($emailTo == '') ){
$emailTo = get_option('admin_email');
}
$subject = 'Listing Inquiry from '.$name;
$body = "Name: $name \n\nEmail: $email \n\nPhone: $phone \n\nListing: $listing \n\nURL: $url \n\nComments: $comments";
$headers = 'From: '.$name.' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;
wp_mail($emailTo, $subject, $body, $headers);
$emailSent = true;
}
} ?>