AWS SES with Meteor

限于喜欢 提交于 2019-12-02 02:42:41

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.

To enable SMTP access with AWS SES:

  1. Log into the AWS Management Console
  2. Select the appropriate region where you set up SES.
  3. Select SES from the list of Application Services
  4. Click the SMTP Settings menu item in the left menu
  5. Click the Create My SMTP Credentials button
  6. Use the default IAM username that's provided. This is a special IAM user that will only have access to the SMTP server. You shouldn't use your main IAM username/password when accessing the SMTP server.
  7. Make sure to note the SMTP server name. You'll need it later.
  8. After the account is created download the credentials.

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';

Please note that both the sending and receiving email addresses must be verified in the AWS SES management console if you haven't received production access yet. If you don't do this Meteor will throw an error in the console and the message will not be sent.

@brian-shamblen does not answer the question directly, but rather proposes an alternative solution to send emails.

You do not have to set up SMTP on AWS, nor you need to set environment variable inside your project process.env.MAIL_URL.

  • Log into the AWS Management Console
  • Go to IAM Service (!!not SES)
  • Create new IAM User
  • Save credentials (AWSAccessKeyID and AWSSecretKey). These are the credentials you'll use in Email.configSES({...})
  • Create inline Policy for this user:
{   
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ses:SendEmail",
                "ses:SendRawEmail"
            ],
            "Resource": "*"
        }
    ]
}
  • Make sure to use verified domail in Accounts.emailTemplates.from. In order to verify domain in AWS, go to SES services -> Domains and follow instructions.

This should let you send emails.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!