简体   繁体   English

将附件与来自 Nodejs 中 Sendgrid 的原始 mime 消息分开

[英]Separate attachment from Raw mime message from Sendgrid in Nodejs

I have a response coming from sendgrid inbound webhook, and it have some attachment, but is there any way we can separate the attachment from the full email payload.我有一个来自 sendgrid 入站 webhook 的响应,它有一些附件,但是有什么方法可以将附件与完整的 email 有效负载分开。

This is the email body we receive from sendgrid below: I have shortened the email body and included important property including the X-Attachment-Id and right below is base64 attachment.这是我们从下面的 sendgrid 收到的 email 正文:我缩短了 email 正文并包括重要属性,包括 X-Attachment-Id 和右下方是 base64 附件。

body = {
    dkim: '{@gmail.com : pass}',
    subject: 'Subject 1',
    email: 'Received: by mx0121p1iad2.sendgrid.net with SMTP id U3SN4cHg8C Wed, 21 Sep 
            2022 16:36:45 +0000 (UTC)\n' +
            '--000000000000de567405e9328c5d\n' +
            'Content-Type: application/pdf; name="dummy copy.pdf"\n' +
            'Content-Disposition: attachment; filename="dummy copy.pdf"\n' +
            'Content-Transfer-Encoding: base64\n' +
            'Content-ID: <f_l8buktdz0>\n' +
            'X-Attachment-Id: f_l8buktdz0\n' +
            '\n' +
            'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp\n' +
            'bHRlci9GbGF0ZURlY29kZT4+CnN0cmVhbQp4nD2OywoCMQxF9/mKu3YRk7bp\n' +
            'tDAIDuh+oOAP+AAXgrOZ37etjmSTe3ISIljpDYGwwrKxRwrKGcsNlx1e31mt\n' +'\n' +
            '--000000000000de567405e9328c5d\n' }

I know I can use string methods to separate the part below the X-Attachment-ID property for making the attachment which is in base64 format, but is there any other way from sendgrid so we can separate any number of attachments.我知道我可以使用字符串方法来分隔 X-Attachment-ID 属性下方的部分,以制作 base64 格式的附件,但是 sendgrid 还有其他方法可以分隔任意数量的附件。

Twilio developer evangelist here. Twilio 开发人员布道师在这里。

This will most likely be resolved via code implementation with the Parse Webhook on the endpoint that you are consuming Parse payload information too.这很可能会通过在您也在使用 Parse 有效负载信息的端点上使用 Parse Webhook 的代码实现来解决。

This SO answer may be helpful . 这个 SO 答案可能会有所帮助

Additionally, if you are not already, we do recommend that you select "POST the raw, full MIME message" in your Inbound Parse Settings under Settings > Inbound Parse in the SendGrid UI.此外,如果您还没有,我们建议您在 SendGrid UI 的 Settings > Inbound Parse 下的 Inbound Parse Settings 中“POST the raw, full MIME message”。

Let me know if this helps at all!让我知道这是否有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM