F
F
freeman02042018-03-12 20:03:57
WordPress
freeman0204, 2018-03-12 20:03:57

How to correctly write the path to the file in wp_mail?

Standard Shipping

// удалим фильтры, которые могут изменять заголовок $headers
// remove_all_filters( 'wp_mail_from' );
// remove_all_filters( 'wp_mail_from_name' );

$attachments = array(WP_CONTENT_DIR . '/uploads/attach.zip');
$headers = 'From: My Name <[email protected]>' . "\r\n";

wp_mail('[email protected]', 'Тема', 'Содержание', $headers, $attachments);

// [email protected] - кому отправляем.

I take the path from the file and cut it to the uploads folder, but it doesn't work, why?
$download_form = get_field("download_form", 489);
  if($download_form) {
    $download_form_sub = substr($download_form['url'], 27);
    $attachments = array(WP_CONTENT_DIR . $download_form_sub);
    wp_mail($email, 'ggg', $name, 'tyy', $attachments);
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2018-03-13
@HeadOnFire

WP_CONTENT_DIR returns the path in the file system. I doubt you need it. Rather, WP_CONTENT_URL is needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question