6

我通过aws-sdkfor Nodejs 发送电子邮件,如下所示:

const params = {
    Destination: {
        ToAddresses: [... ],
    },
    Message: {
        Body: {
            Html: {
                Data: `...`,
                Charset: 'utf-8'
            },
        },
        Subject: {
            Data: `...`,
            Charset: 'utf-8'
        }
    },
    Source: 'support@mydomain.com',
    ReturnPath: 'support@mydomain.com',
};
awsConfig.ses.sendEmail(params, (err, data))

收到的电子邮件在 Gmail 中如下所示: 收到电子邮件

但是,我想知道如何更改此名称:

目前发件人名称是support,因为发件人电子邮件是support@mydomain.com。但我希望它被如下公司取代GitHub

提前感谢您的帮助!

4

2 回答 2

10

这是我最终做的事情:我将Source参数中的属性设置为

'CompanyName <support@mydomain.com>'

感谢@Neil Lunn

于 2018-11-25T14:14:43.123 回答
-1

您可以使用此语法

// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region 
AWS.config.update({region: 'REGION'});

// Create sendEmail params 
var params = {
  Destination: { /* required */
    CcAddresses: [
      'EMAIL_ADDRESS',
      /* more items */
    ],
    ToAddresses: [
      'EMAIL_ADDRESS',
      /* more items */
    ]
  },
  Message: { /* required */
    Body: { /* required */
      Html: {
       Charset: "UTF-8",
       Data: "HTML_FORMAT_BODY"
      },
      Text: {
       Charset: "UTF-8",
       Data: "TEXT_FORMAT_BODY"
      }
     },
     Subject: {
      Charset: 'UTF-8',
      Data: 'Test email'
     }
    },
  Source: 'SENDER_EMAIL_ADDRESS', /* required */
  ReplyToAddresses: [
      'EMAIL_ADDRESS',
    /* more items */
  ],
};       

// Create the promise and SES service object
var sendPromise = new AWS.SES({apiVersion: '2010-12-01'}).sendEmail(params).promise();

// Handle promise's fulfilled/rejected states
sendPromise.then(
  function(data) {
    console.log(data.MessageId);
  }).catch(
    function(err) {
    console.error(err, err.stack);
  });
于 2018-11-25T13:52:38.513 回答