Closed d4mation closed 6 years ago
I'm wondering if just writing a file is safer? I don't know much about how you're doing it now, and it could just be an edge case for this guy, but it did happen. If we delete the file immediately, there's no downside right? Maybe that can be default and if we test and find there are issues writing to the server, we can go back to your method? Not sure, just thinking out loud.
Well, what's weird is that there shouldn't be any issues with the way RBP Support does it now. It uses built-in PHP Mailer methods to accomplish this, and PHP Mailer is what wp_mail()
uses behind-the-scenes. We hook into the PHP Mailer object being used when we call wp_mail()
to attach it as a String rather than reading the file which is what wp_mail()
supports normally.
Unless a plugin is highjacking emails (similar to something like SparkPost) so that it isn't able to do its thing correctly it should not have any problems. So, writing/deleting the file may be safer but if something is highjacking the email process it is hard to account for that since that could technically break normal file attachments too.
I'm willing to convert it over to a normal file attachment that is uploaded and then deleted/overwritten on the server. But I kind of want to wait to see if this happens again with a different customer first just so that we have some more data on the problem.
Got a working one for Gantt Charts come in (https://secure.helpscout.net/conversation/488700619/511). I'd like to see a working one from LD GB specifically though before I rule this out as entirely a problem with that guy's server.
Here's a working one from LD GB: https://secure.helpscout.net/conversation/501303007/531?folderId=955384
I'm going to close this Issue for now, but open another one based on https://secure.helpscout.net/conversation/499931424/527?folderId=955387
We haven't had too many RBP Support emails come in, but out of the ones that have, I think only one has had the Debug File come in properly.
This bug seems to be the same as what was experiencing when I discovered this bug in the WP SparkPost plugin (Which RBP.com uses to send mail) in SparkPost/wordpress-sparkpost#133. My fix for this however has not been released, so anyone using this plugin for Mailing right now would experience this bug.
I tested this on
rbmtest
without any special Mailing Plugin active and had it send directly to my Inbox rather than HelpScout (Just to avoid clutter there) and it worked just fine.My only guess would be that something in these guys' server/email configuration is blocking the proper creation of the attachment as a String Buffer. It would most likely be a Mailing Plugin like SparkPost trying to treat the String Buffer as a File Path and not finding any File Contents so it returns an empty string when building the Attachment (This was the problem in SparkPost). We could do what @joelworsham did in CD Pro and have it store to an actual file and attach it that way, then after the mail is sent, delete it (Or just always overwrite the file first for each sent mail).
I wanted to avoid creating an actual file on the server since I did not see it as necessary, but if that's what it takes to get around sub-optimal setups than it may be worth doing.
What do you think, @joelworsham? I've only noticed this in LD GB Support Emails, but that's primarily because I've only had one person use the RBP Support form in a different plugin and it did seem to work there. Your code does work though, so I don't think this is an issue with LD GB but rather with their Server config.
I did some digging to find that other failed one and it turns out that all the failed ones are from the same sender. So I'm less concerned about this for now, given it may be localized to something weird on this guy's server. I tagged the conversations on HelpScout as
failed-rbp-support-debug-file
in case we ever need to reference the Email Headers for them, but I took a quick peek and nothing seemed to jump out at me.