Answer the question
In order to leave comments, you need to log in
The wp_mail function sends a lot of emails to me. Code inside. What could be wrong there?
my code is in function.php, where if the condition is triggered, then mail is sent with a redirect to the same page, that is, if I have two posts from the form that are not empty, then a letter is sent.
add_action( 'init', 'email_send' );
function email_send()
{
if (!empty($_POST['send_email']) and !empty($_POST['send_mess'])):
wp_mail(get_post_meta(95, 'email', true), 'письмо с сайта: ' . $_SERVER['HTTP_HOST'], 'сообщение: ' . $_POST['send_mess'] . "\n" . 'почта отправителя: ' . $_POST['send_email']); //, $headers, $attachments
$_SESSION['success'] = 'Ваше сообщение отправленно!';
wp_redirect($_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '#form');
exit;
endif;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question