简体   繁体   English

使用nodejs使用aws-sdk(Amazon SES)发送带有附件的电子邮件

[英]Send Email with attachment using aws-sdk(Amazon SES) using nodejs

Hello, I am trying to send email with attachment ,using 您好,我正在尝试使用附件发送带有附件的电子邮件

var params = {
        RawMessage: {
            From: "rajit.garg@daffodilsw.com",
            To: "rajit.garg@daffodilsw.com",
            Date: new Date(),
            Subject: "Hello",
            "Accept-Language": "en-US",
            "Content-Language": "en-US",
            "Content-Type": "text/plain", charset: "us-ascii",
            "Content-Transfer-Encoding": "quoted-printable",
            "MIME-Version": 1.0,
            Data: "Hello, I hope you are having a good day."
        },
        Destinations: [
            "rajit.garg@daffodilsw.com"
        ],
        Source: "rajit.garg@daffodilsw.com"
    };

    ses.sendRawEmail(params, function (err, data) {
        if (err) console.log("err>>" + err, err.stack); // an error occurred
        else     console.log("data>>>" + JSON.stringify(data));           // successful response
    });

but I am getting error 但我得到了错误

UnexpectedParameter: Unexpected key 'From' found in params.RawMessage * UnexpectedParameter: Unexpected key 'To' found in params.RawMessage * UnexpectedParameter: Unexpected key 'Date' found in params.RawMessage * UnexpectedParameter: Unexpected key 'Subject' found in params.RawMessage * UnexpectedParameter: Unexpected key 'Accept-Language' found in params.RawMessage * UnexpectedParameter: Unexpected key 'Content-Language' found in params.RawMessage * UnexpectedParameter: Unexpected key 'Content-Type' found in params.RawMessage * UnexpectedParameter: Unexpected key 'charset' found in params.RawMessage * UnexpectedParameter: Unexpected key 'Content-Transfer-Encoding' found in params.RawMessage * UnexpectedParameter: Unexpected key 'MIME-Version' found in params.RawMessage UnexpectedParameter:在params.RawMessage中发现了意外的键'From'* UnexpectedParameter:在params.RawMessage中发现了意外的键'To'*在params.RawMessage中发现了意外的键'日期'* UnexpectedParameter:在params中发现了意外的键'Subject'。 RawMessage * UnexpectedParameter:在params.RawMessage中发现了意外的键'Accept-Language'* UnexpectedParameter:在params.RawMessage中发现了意外的键'Content-Language'* UnexpectedParameter:在params.RawMessage中发现了意外的键'Content-Type'* UnexpectedParameter:意外了在params.RawMessage中找到键'charset'* UnexpectedParameter:在params.RawMessage中找到键'Content-Transfer-Encoding'* UnexpectedParameter:在params.RawMessage中找到键'MIME-Version'

I know I am not using the correct format of params , but i have not got the right format anywhere, please help me..... Thanks in advance... 我知道我没有使用正确的params格式,但是我在任何地方都没有正确的格式,请帮助我.....在此先感谢...

According to the documentation , the field RawMessage only contains a Data property and nothing else. 根据文档 ,字段RawMessage仅包含Data属性,而没有其他内容。 The Data field contains an entire raw email message - including the headers and body (or bodies), all properly formatted (escaping, encoding) and delimited (proper number of newlines). Data字段包含完整的原始电子邮件消息-包括标题和正文(所有正文),格式正确(转义,编码)和定界(正确的换行数)。

You might be looking for sendEmail , which allows you to set headers such as the 'To', 'From' and 'Subject' fields as key-value pairs. 您可能正在寻找sendEmail ,它允许您将标头(例如'To','From'和'Subject'字段)设置为key-value对。

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

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