Support » Fixing WordPress » wp_mail attachment
4 years, 12 months ago
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 <email@example.com>' . "\r\n";
$attachments = get_bloginfo('template_directory') . '/test.txt';
wp_mail( 'firstname.lastname@example.org', 'testmail', 'This is a testmail', $headers, $attachments);
– 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?
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');