Binary Attachments
-
I’ve been trying out FluentSMTP with an upcoming release of my StageShow plugin, and I have experienced a problem. With basic emails it works fine, but my plugin sends emails that can have a couple of embedded images and with these FluentSMTP fails. One image (a logo) is read from a file and the other (a Barcode) is generated “on the fly” and passed to the Mailer as a binary image. In both cases the images are added by calling public methods of the PHPMailer class (addEmbeddedImage and addStringEmbeddedImage respectively) in an action handler of the phpmailer_init action. My implementation works fine with the default WP Mailer (PHPMailer).
I’ve configured FluentSMTP to use a SMTP Server and the test email works fine. However the emails with the Barcode do not get sent, an exception is thrown and the action handler of the wp_mail_failed action is being called. The error object does not appear to have any useful data.
If I comment out the call to addStringEmbeddedImage, the email is sent successfully, so I suspect that FluentSMTP has a problem with attachments that are added as binary images rather than a file path.
I’ve had a look at the FluentSMTP code and think I may have found the problem. In app/Services/Mailer/Providers/Smtp/Handler.php. line 98 calls addAttachment() passing $attachment[0] as the first parameter. This function expects a file path, but for attachments added as an image this element is the image of the file (there is no file path as there is no file), and therefore function throws an exception. It also looks like the other contents of the attachment element are ignored, so my setting of the disposition to “inline” is lost.
Is this something that you are aware of? Would you expect FluentSMTP to be able to handle attachments added by the addStringEmbeddedImage method?
Many Thanks
- The topic ‘Binary Attachments’ is closed to new replies.