0

I created a form for mail sending, but it does not work. Email function is enabled in php.

if (!$error_msg) {
    $to = "[email protected]";
    $headers[] = 'Content-Type: text/html; charset=UTF-8';
    $headers[] = 'From: ' . $fullname . ' <' . $mail . '>' . "\r\n";
    wp_mail($to, $object, $message, $headers);
    $error_msg_type = 'success';
    $error_msg = __('cont_mail_sent', 'Theme');
}

What is wrong?

4
  • wp_mail ( $to, $subject, $message, $headers, $attachments ) Always read docs before asking. You can also find examples if you scroll down.
    – N00b
    Apr 29, 2016 at 11:50
  • $attachments is not optional?
    – WalterV
    Apr 29, 2016 at 11:51
  • $attachements is optional. does $object represent $subject? Are you declaring it? It's required. Also add more code, if all required fields are there, you have a bug somewhere else.
    – N00b
    Apr 29, 2016 at 11:53
  • Yes all is declared, only $headers is an array
    – WalterV
    Apr 29, 2016 at 11:55

1 Answer 1

0

f you're using anything that allows you to configure SMTP within WordPress, take it out.

Then put everything into a function:

add_action('init','delay_until_init');
function delay_until_init(){
   // call wp_mail() here
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.