Support » Fixing WordPress » wp_mail attachment

  • Resolved Peter_L

    (@peter_l)


    Hello,

    I am building a contactpage, page-contact.php.
    I have something more complex in mind but as a test, I tried to add an attachment to wp_mail and it doesn’t work. And that is my problem.

    The mail itself works fine but there simply isn’t an attachment. I use a simple text document, test.txt, that is located in the root of my there folder.

    This is a simplified version of my code:

    $headers = 'From: My Name <myname@mydomain.com>' . "\r\n";
    $attachments = get_bloginfo('template_directory') . '/test.txt';
    wp_mail( 'myname@mydomain.com', 'testmail', 'This is a testmail', $headers, $attachments);

    Possible problems:
    – path to attachment file is wrong
    – $headers: content type is wrong
    – attachment file is too small…?
    – wrong setting in php.ini

    None of these possibilities I have an answer to.
    So here is my question: What am I doing wring or What could I be doing wrong?

Viewing 1 replies (of 1 total)
  • I found the problem, the path to the file was wrong.

    I uploaded a new test file using the wordpress media manager. Path looks like this now:

    $attachments = array(WP_CONTENT_DIR . '/uploads/2012/02/test.txt');

Viewing 1 replies (of 1 total)
  • The topic ‘wp_mail attachment’ is closed to new replies.