M
M
mrWan2018-02-04 22:00:22
WordPress
mrWan, 2018-02-04 22:00:22

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;
}

After sending, a letter arrives, but some incomprehensible letters also come with the necessary letter5a7758419fc7f744104418.jpeg

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question