Plugin Contributor
rajuru
(@rajuru)
@tii
Can you give some example usages? Like how did you invoke the wp_mail?
Thanks
Thread Starter
Tii
(@tii)
Here is the test code I was using :
$to = "[email protected]";
$headers = array();
$attachments = array();
$from = get_option('admin_email');
$subject = sanitize_post($_POST['subject']);
$headers[] = 'Cc: ' . $from;
$content = sanitize_post($_POST['content']);
$pdf_path = ABSPATH.'/pdf/document.pdf';
$attachments[] = $pdf_path;
if (wp_mail($to, $subject, $content, $headers, $attachments)) {
echo "SENT";
}
but, as I said, the attachment showed up in the json and, this code is working with the sendgird plugin so it seems to me like I attached it correctly…
Plugin Contributor
rajuru
(@rajuru)
Thanks for the snippet. What sparkpost mailer (smtp/http) are you using?
Plugin Contributor
rajuru
(@rajuru)
I see you said JSON, so I assume you are using HTTP mailer. Is that right?
Plugin Contributor
rajuru
(@rajuru)
@tii
I just tested attachment with HTTP Mailer and seems it’s working.
`
$pdf_path = dirname(__FILE__) . ‘/hello.txt’;
$headers = array();
$attachments= array($pdf_path);
$result = wp_mail($recipient,
$subject,
$body,
$headers,
$attachments
);`
I got the email with attachment delivered correctly.
Can you post the Request Body (shown in verbose log) so that I can inspect? Please mask any private data.
Also, are you using any Template (Specified a template ID in the plugin settings)?
Thread Starter
Tii
(@tii)
Your remark was good, I removed the tmeplate and the attachment went thru !
why is that and how can I use the template with an attachment ?
-
This reply was modified 9 years, 4 months ago by
Tii.
Plugin Contributor
rajuru
(@rajuru)
You can find more info about template and attachment here.
You can also specify template ID in the settings but when you wanna send attachments, you can use plugin hooks to remove the template just before calling wp_mail (and remove the filter after wp_mail).
Thread Starter
Tii
(@tii)
well, I want to send email with a template and an attachment, otherwise, I’m not interested as I already have a working solution with Sendgrid.
I’m not gonna hack my way to use Sparkpost. I understand that it’s a Sparkpost problem but, I think the plugin should inform it’s users that you cannot send an attachment with a template !
Plugin Contributor
rajuru
(@rajuru)
Sorry to know it’s not working as you expected. And unfortunately, it’s not a drop-in replacement of other plugins too.
Thanks for suggestion about clarifying the issue. I’ve just logged in issue https://github.com/SparkPost/wordpress-sparkpost/issues/96.
Thanks