使用 Meteor 的 AWS SES [英] AWS SES with Meteor

查看:41
本文介绍了使用 Meteor 的 AWS SES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一个 Meteor 包来与由@Akshat 构建的名为 tarang:email-ses 的 AWS SES 交互.

I'm trying to out a Meteor package to interface with AWS SES called tarang:email-ses built by @Akshat.

我使用的是在 AWS EC2 实例上运行的 Meteor @1.*.当我使用下面的代码进行测试时,没有发送电子邮件.

I'm on Meteor @1.* running on a AWS EC2 instance. When I a test run with the code below, no email was sent out.

我已经设置了 AWS 访问密钥 ID 和秘密访问密钥并在此处使用:

I've set up the AWS access key ID and secret access key and use it here:

Meteor.startup(function () {    
  Email.configSES({
    AWSAccessKeyID: 'access-key',
    AWSSecretKey: 'secret-key'
  });
});

我还验证了我的电子邮件和域.在这里,我确保我是从经过验证的发件人 SES 地址发送的:

I've also verified my emails and domain. Here I make sure I'm sending from my verified sender SES address:

Accounts.emailTemplates.from = 'Domain Name <support@domain-name.com>';

然后在 Meteor 方法中,我创建一个新用户并像这样发送和注册电子邮件(如果我部署到meteor.com,这会起作用,当然没有 Accounts.emailTemplates.from):

Then in a Meteor method, I create a new user and send and enrollment email like so (this works if I deploy to meteor.com, without the Accounts.emailTemplates.from of course):

if (Meteor.user() && adminUser(this.userId)) {
  var accountId = Accounts.createUser({
    'username': doc.name,
    'email': doc.email
  });
  Accounts.sendEnrollmentEmail(accountId);
}

问题

为 email-ses 包设置的代码是否正确?

Questions

Is the code to set things up for the email-ses package correct?

我认为这个包抽象出 Amazon SES API 来发送电子邮件(并允许本地 Meteor 电子邮件调用).是否需要在 AWS 上设置 SMTP?

I thought this package abstracted out the Amazon SES API to Send Email (and allowed for native Meteor email calls). Is there a requirement to set up SMTP on AWS?

推荐答案

要在 Meteor 中发送电子邮件,最简单的方法是使用 process.env.MAIL_URL 变量设置 SMTP 服务器和用户名信息.AccountsEmail 包将在您发送消息时自动使用它来访问 SMTP 服务器.

To send email in Meteor the easiest thing to do is to set the SMTP server and username information using process.env.MAIL_URL variable. The Accounts and Email packages will automatically use it to access the SMTP server whenever you send a message.

通过 AWS SES 启用 SMTP 访问:

To enable SMTP access with AWS SES:

  1. 登录 AWS 管理控制台
  2. 选择您设置 SES 的适当区域.
  3. 从应用服务列表中选择 SES
  4. 点击左侧菜单中的SMTP设置菜单项
  5. 点击创建我的 SMTP 凭据按钮
  6. 使用提供的默认 IAM 用户名.这是一个特殊的 IAM 用户,只能访问 SMTP 服务器.访问 SMTP 服务器时,您不应使用主 IAM 用户名/密码.
  7. 请务必记下 SMTP 服务器名称.稍后您将需要它.
  8. 创建帐户后,下载凭据.

既然您已经设置了一个帐户,只需将以下行复制并粘贴到您的 Meteor 启动文件的顶部,并从您刚刚下载的凭据文件中的值和服务器名称中替换用户名和密码提供.

Now that you have an account set up, simply copy and paste the following line to the top of your Meteor startup file and replace the username and password from the values in the credential file that you just downloaded and the server name that was provided.

process.env.MAIL_URL = 'smtp://username:password@smtp-server-name:465';

请注意,如果您尚未获得生产访问权限,则必须在 AWS SES 管理控制台中验证发送和接收电子邮件地址.如果不这样做,Meteor 将在控制台中抛出错误并且不会发送消息.

这篇关于使用 Meteor 的 AWS SES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆