A user reported that SparkPost was rejecting emails with the error “X-MSYS-API ‘campaign_id’ is limited to 64 bytes,” suspecting that Discourse was generating a campaign ID that exceeded this limit, possibly due to a long domain name. The issue was traced to the X-MSYS-API header logic in discourse/lib/email/sender.rb5. While a temporary workaround was suggested to truncate the ID to 63 characters 12, the core problem was identified as the header implementation being broken according to SparkPost documentation 5. Ultimately, a developer confirmed that the custom header was unnecessary since SparkPost provides the message_id in the email body, and a fix was committed to remove the problematic code entirely 15. Users expressed gratitude for the quick resolution and the availability of the patch in the latest updates 16.
when configuring SparkPost my emails were getting rejected by policy. with this error message:
“X-MSYS-API ‘campaign_id’ is limited to 64 bytes”
Is it possible that Discourse is generating a long campaign_id for my emails, as it never happened before but this time i used a long domain name of about 34 characters?
Support for this header was added in this commit, and its use of the X-MSYS-API header is definitely broken according to the SparkPost docs. I’m thinking the code that sets that header just needs to be nuked from orbit. Any disagreements?
You could hand-edit the code in the container, which would persist until the next rebuild, but if you hang around for a little while, we’ll get it fixed properly, and you can just rebuild with the fixed code.
You could change “tests-passed” in app.yml to the id of a commit before the one that introduced the error. I made a post about that once, but can’t find it right now.
Oh,but if the database has migrated past you then that might not work.
Or it can be solved from within line #143 at file : discourse/lib/email/sender.rb @message.header[‘X-MSYS-API’] = { campaign_id: @message.message_id }.to_json