简体   繁体   English

使用Amazon SES和Node.js弹出电子邮件的代码

[英]Code for bouncing emails using Amazon SES and Node.js

I'm able to send the emails to my recipients using Amazon SES service with Node.js but I'm unable to see if the emails are bouncing back if I enter a wrong recipients emailIDs. 我可以使用带有Node.js的Amazon SES服务将电子邮件发送给我的收件人,但如果输入错误的收件人emailID,我无法查看电子邮件是否正在反弹。

Please let me know if I need to add something to get the bounce back response. 如果我需要添加一些东西以获得反弹回复,请告诉我。

I am sending the email using the following code: 我使用以下代码发送电子邮件:

app.get('/emailData', function (req, res) {
  var emailfrom = "sender@example.com";
  var emailto = "receiver@example.com";

  var ses_mail = "From: 'AWS' <" + emailfrom + ">\n";
  ses_mail = ses_mail + "To: " + emailto + "\n";


  var params = {
    RawMessage: { Data: new Buffer(ses_mail) },
    Destinations: [ emailto ],
  };

  ses.sendRawEmail(params, function(err, data) {
    if(err) {
      res.send(err);
    } 
    else {
      res.send(data);
    }
  )};        
});

You need to use Amazon SES Notifications in order to monitor bounce or complaint events. 您需要使用Amazon SES通知来监控退回或投诉事件。 You cannot get immediate feedback when sending ( ses.sendRawEmail doesn't error). 发送时无法获得即时反馈( ses.sendRawEmail不会出错)。

Amazon SES can notify you of bounce or complaint events in three ways: by sending a notification email, by notifying an Amazon SNS topic, or by publishing sending events. Amazon SES可以通过三种方式通知您退回或投诉事件:发送通知电子邮件,通知Amazon SNS主题或发布发送事件。

You can have Amazon SES notify a SNS topic in case of a bounce event and have a Lambda function subscribe to this topic. 如果发生跳出事件,您可以让Amazon SES通知SNS主题,并让Lambda函数订阅此主题。 This way you can implement you own logic in case of a bounce. 这样,您可以在弹跳时实现自己的逻辑。

See Monitoring Using Amazon SES Notifications . 请参阅使用Amazon SES通知进行监控

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

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