亚马逊ses如何发qq

by Kangze Huang

黄康泽

使用Amazon SES发送电子邮件 (Sending emails with Amazon SES)

完整的AWS Web样板-教程3 (The Complete AWS Web Boilerplate — Tutorial 3)

目录 (Table of Contents)

Part 0: Introduction to the Complete AWS Web Boilerplate

第0部分: 完整的AWS Web Boilerplate简介

Part 1: User Authentication with AWS Cognito (3 parts)

第1部分: 使用AWS Cognito进行用户身份验证 (三部分)

Part 2: Saving File Storage Costs with Amazon S3 (1 part)

第2部分: 使用Amazon S3节省文件存储成本 (第1部分)

Part 3: Sending Emails with Amazon SES (1 part)

第3部分: 使用Amazon SES发送电子邮件 (第1部分)

Part 4: Manage Users and Permissions with AWS IAM [Coming Soon]

第4部分:使用AWS IAM管理用户和权限[即将推出]

Part 5: Cloud Server Hosting with AWS EC2 and ELB[Coming Soon]

第5部分:使用AWS EC2和ELB托管云服务器[即将推出]

Part 6: The MongoDB Killer: AWS DynamoDB [Coming Soon]

第6部分:MongoDB杀手:: AWS DynamoDB [即将推出]

Part 7: Painless SQL Scaling using AWS RDS [Coming Soon]

第7部分:使用AWS RDS进行无痛SQL扩展[即将推出]

Part 8: Serverless Architecture with Amazon Lambda [Coming Soon]

第8部分:使用Amazon Lambda的无服务器架构[即将推出]

Download the Github here.

在此处下载Github。

建立 (Setup)

Sending emails with Amazon SES is really straightforward. Let’s start at the set-up. Go to Amazon SES and click Email Addresses in the sidebar. Then click Verify a New Email Address and enter an email you want to use for messaging in the app.

使用Amazon SES发送电子邮件非常简单。 让我们从设置开始。 转到Amazon SES,然后单击侧边栏中的电子邮件地址 。 然后单击“ 验证新电子邮件地址” ,然后在应用程序中输入要用于发送消息的电子邮件。

Now go to your email provider and click the verification link. After verifying, go back to Amazon SES Email Addresses tab. You should now see your email verified.

现在转到您的电子邮件提供商,然后单击验证链接。 验证后,返回到Amazon SES 电子邮件地址选项卡。 您现在应该看到您的电子邮件已验证。

This was necessary for 2 reasons. First is that we need an email for sending a message, and the second is because we are in a sandbox environment. A sandbox environment means you can only send and receive emails from verified addresses, and prevents you from spamming people. This is all the set-up we need for this boilerplate.

这有两个原因。 首先是我们需要一封电子邮件来发送消息,其次是因为我们处于沙盒环境中。 沙盒环境意味着您只能从经过验证的地址发送和接收电子邮件,并且可以防止向他人发送垃圾邮件。 这就是我们需要的所有样板设置。

If you want be able to send emails to any email address, you need to make a written request to Amazon to graduate from the sandbox environment. To do this, navigate to the top-right hand corner at Support > Support Center.

如果您希望能够将电子邮件发送到任何电子邮件地址,则需要向亚马逊提出书面要求,以便从沙盒环境中毕业。 为此,请导航至“ 支持”gt;上的右上角 支持中心

At this next screen, click Create case.

在下一个屏幕上,点击Create case

This is a straightforward form, but we’ll briefly explain. Select Service Limit Increase and set the Limit Type to SES Sending Limits. Now create 2 requests, one where Limit is Desired Daily Sending Quota (how many emails can be sent in one day), and the other where Limit is Desired Maximum Send Rate. Set the New limit value to the amount that you need. Finally, optionally set the Mail Type as it increases you odds of approval. Use transactional if your emails are generated as a request of a user’s activity. There are others available for other use cases.

这是一种简单的形式,但我们将简要说明。 选择服务限制增加,然后将限制类型设置为SES发送限制 。 现在创建2个请求,一个请求的“ 限制”是“ 每日期望的发送配额” (一天可以发送多少电子邮件),另一个请求的“ 限制”是“ 期望的最大发送速率” 。 将新限制值设置为所需的数量。 最后,可以选择设置“邮件类型”,因为它增加了批准的几率。 如果您的电子邮件是根据用户活动的请求生成的,则使用事务性。 还有其他可供其他用例使用的情况。

The rest of the request is easy. Make sure you agree to comply with the Terms of Service, and you have a process to handle bounces and complaints (for when users mark your email as spam). Finally, give a brief explanation of your use case.

其余的请求很容易。 确保您同意遵守服务条款,并且有一个处理退信和投诉的程序 (当用户将您的电子邮件标记为垃圾邮件时)。 最后,简要说明您的用例。

Submit your code and you should get an email from Amazon with the results of your service increase request. Once approved, your app can send messages to any email.

提交您的代码,您应该从亚马逊收到一封电子邮件,其中包含您的服务增加请求的结果。 获得批准后,您的应用可以将消息发送到任何电子邮件。

代码 (The Code)

We’re ready to dig into the code! Go to App/src/api/aws/aws_ses.js where the bulk of the code resides. Let’s take a look at the main function sendAWSEmail():

我们准备深入研究代码! 转到大部分代码所在的App/src/api/aws/aws_ses.js 。 让我们看一下主要功能sendAWSEmail()

export function sendAWSEmail(email, message){ const ses = new AWS.SES({  region: 'us-east-1' }) const p = new Promise((res, rej)=>{  if(!email|| message){   rej('Missing user email or message content')  }else{   const params = createInquiryParamsConfig(email, message)   // console.log('Sending email with attached params!')   AWS.config.credentials.refresh(function(){    // console.log(AWS.config.credentials)    ses.sendEmail(params, function(err, data) {      if(err){        // console.log(err, err.stack); // an error occurred        rej(err)      }else{       // console.log(data);           // successful response     res('Success! Email sent')      }    })   })  } }) return p}

This is extremely straightforward. We receive two arguments, an email to send to, and a message to be sent. The first thing we do in this function is instantiate the AWS SES object for interacting with AWS by simply passing in the region. Next we check if there is a recipient email and a message. If both are provided, then we can actually send the email.

这非常简单。 我们收到两个参数,即要发送给的电子邮件和要发送的消息。 我们在此功能中要做的第一件事是通过简单地传入区域来实例化AWS SES对象以与AWS进行交互。 接下来,我们检查是否有收件人电子邮件和消息。 如果两者都提供,那么我们实际上可以发送电子邮件。

Assuming we have both a recipient email and message, we will create a params object for AWS SES to read for all the info & options necessary. This params object is created with createInquiryParamsConfig(). Before we dive into that rabbit hole, let’s just quickly finish up explaining the rest of sendAWSEmail(). We refresh AWS Cognito user’s credentials (that we set with AWS Cognito, explained in my other tutorial) and call ses.sendEmail with params and a response callback passed in. Reject the promise if there is an error, and resolve with a success message if there is no error. ses.sendEmail is the only AWS function we will use, and everything else is we need is determined in params.

假设我们同时拥有收件人电子邮件和消息,我们将为AWS SES创建一个params对象,以读取所有必要的信息和选项。 该params对象是使用createInquiryParamsConfig()创建的。 在深入sendAWSEmail()这个兔子洞之前,让我们快速完成其余的sendAWSEmail()解释。 我们刷新AWS Cognito用户的凭证(我们使用AWS Cognito设置的凭证,在我的其他教程中进行了说明 ),并使用ses.sendEmailparams和响应回调调用ses.sendEmail 。没有错误。 ses.sendEmail是我们将要使用的唯一AWS函数,而我们需要的其他一切都在params确定。

Now let’s see how to make params with createInquiryParamsConfig().

现在,让我们看看如何使用createInquiryParamsConfig()进行params设置。

function createInquiryParamsConfig(email, message){ const params = {   Destination: {      BccAddresses: [],     CcAddresses: [],     ToAddresses: [ email ]   },   Message: {      Body: {        Html: {         Data: generateHTMLInquiryEmail(landlordEmail, message),         Charset: 'UTF-8'       }     },     Subject: {        Data: 'Kangzeroos Boilerplate says hi ' + email,       Charset: 'UTF-8'     }   },   Source: 'yourApp@gmail.com',    ReplyToAddresses: [ 'yourApp@gmail.com' ],   ReturnPath: 'yourApp@gmail.com' } return params}

Pretty straightforward, we pass in email and message, and return a big javascript object. All the values you see here are necessary, but you can add a ton of other optional configurations too. The function we must pay attention to is generateHTMLInquiryEmail(). Let’s look at that.

非常简单,我们传递emailmessage ,并返回一个大的javascript对象。 您在此处看到的所有值都是必需的,但您也可以添加大量其他可选配置。 我们必须注意的函数是generateHTMLInquiryEmail() 。 让我们看看。

function generateHTMLInquiryEmail(email, message){ return `  <!DOCTYPE html>  <html>    <head>      <meta charset='UTF-8' />      <title>title</title>    </head>    <body>     <table border='0' cellpadding='0' cellspacing='0' height='100%' width='100%' id='bodyTable'>      <tr>          <td align='center' valign='top'>              <table border='0' cellpadding='20' cellspacing='0' width='600' id='emailContainer'>                  <tr style='background-color:#99ccff;'>                      <td align='center' valign='top'>                          <table border='0' cellpadding='20' cellspacing='0' width='100%' id='emailBody'>                              <tr>                                  <td align='center' valign='top' style='color:#337ab7;'>                                      <h3>${message}</h3>                                  </td>                              </tr>                          </table>                      </td>                  </tr>                  <tr style='background-color:#74a9d8;'>                      <td align='center' valign='top'>                          <table border='0' cellpadding='20' cellspacing='0' width='100%' id='emailReply'>                              <tr style='font-size: 1.2rem'>                                  <td align='center' valign='top'>                                      <span style='color:#286090; font-weight:bold;'>Send From:</span> <br/> ${email}                                  </td>                              </tr>                          </table>                      </td>                  </tr>              </table>          </td>      </tr>      </table>    </body>  </html> `}

All we are doing here is creating an HTML file and passing in the email and message to create a custom email. We use ES6 string literals to add in string variables with ${ } like so: <h3>${message}</h3>.

我们在这里所做的就是创建一个HTML文件,并传入emailmessage以创建自定义电子邮件。 我们使用ES6字符串文字以${ }添加字符串变量,如下所示: <h3>${message } </ h3>。

And that’s it! You can use whatever front end code you want, simply pass in an email and message to sendAWSEmail(). Just remember sendAWSEmail() returns a promise, so you will have to handle that accordingly. If you don’t know how to handle promises, check out my other tutorial here.

就是这样! 您可以使用所需的任何前端代码,只需将emailmessagesendAWSEmail() 。 只要记住sendAWSEmail()返回一个promise,就必须相应地处理它。 如果您不知道如何处理承诺,请在此处查看我的其他教程 。

See you next time!

下次见!

目录 (Table of Contents)

Part 0: Introduction to the Complete AWS Web Boilerplate

第0部分: 完整的AWS Web Boilerplate简介

Part 1: User Authentication with AWS Cognito (3 parts)

第1部分: 使用AWS Cognito进行用户身份验证 (3部分)

Part 2: Saving File Storage Costs with Amazon S3 (1 part)

第2部分: 使用Amazon S3节省文件存储成本 (第1部分)

Part 3: Sending Emails with Amazon SES (1 part)

第3部分: 使用Amazon SES发送电子邮件 (第1部分)

Part 4: Manage Users and Permissions with AWS IAM [Coming Soon]

第4部分:使用AWS IAM管理用户和权限[即将推出]

Part 5: Cloud Server Hosting with AWS EC2 and ELB[Coming Soon]

第5部分:使用AWS EC2和ELB托管云服务器[即将推出]

Part 6: The MongoDB Killer: AWS DynamoDB [Coming Soon]

第6部分:MongoDB杀手:: AWS DynamoDB [即将推出]

Part 7: Painless SQL Scaling using AWS RDS [Coming Soon]

第7部分:使用AWS RDS进行无痛SQL扩展[即将推出]

Part 8: Serverless Architecture with Amazon Lambda [Coming Soon]

第8部分:使用Amazon Lambda的无服务器架构[即将推出]

This method was partially used in the deployment of renthero.ca

此方法部分用于renthero.ca的部署中

翻译自: https://www.freecodecamp.org/news/sending-emails-with-amazon-ses-7617e83327b6/

亚马逊ses如何发qq

亚马逊ses如何发qq_使用Amazon SES发送电子邮件相关推荐

  1. 亚马逊通过云计算发力中国市场?表示要适应中国规则

    "亚马逊AWS在中国将有一个新形象,就是云计算的领军人物".2017年8月25日,太和智库发起主办的人工智能论坛上,亚马逊AWS首席云计算技术顾问费良宏作为邀请嘉宾,开始今年在中国 ...

  2. 跨境电商亚马逊单个产品发FBA需要注意哪些事项(一)

    今天给大家讲解一下我们单个产品,我们要发FBA的时候,我们需要去注意的哪些点, 假设一下,我准备要进行一个发货的,但是呢,我们现在就是发FBA的时候,它其实是有很多要求的,你这个产品发FBA,首先,这 ...

  3. 亚马逊 各国站点 链接_使用Amazon S3和HTTPS的简单站点托管

    亚马逊 各国站点 链接 by Georgia Nola 乔治亚·诺拉(Georgia Nola) 使用Amazon S3和HTTPS的简单站点托管 (Simple site hosting with ...

  4. 亚马逊推荐python_使用python查找amazon类别

    我想得到amazon的类别,我计划废弃不用API. 我已经取消了http://www.amazon.com,我已经在Shop By Department下拉列表中抓取了所有的类别和子类别,我创建了一个 ...

  5. 亚马逊云科技 Build On-使用 Amazon KVS 和 Amazon Rekognition 进行实时智能视觉识别

    在观望了亚马逊云科技Build On第一季动手实验后,报名了第二季AIoT主题活动,由于深圳较远,就没有去深圳参加现场活动.(ps:很羡慕去现场的小伙伴,人手一个树莓派,啊啊啊-) Build On ...

  6. 亚马逊ec2 实例删除_在Amazon EC2实例中的Red Hat上安装SQL Server Linux

    亚马逊ec2 实例删除 This article explores the configuration of the Red hat Amazon EC2 instance for SQL Serve ...

  7. python亚马逊运营工具_GitHub - WuLC/AmazonRobot: Amazon商品引流的 python 爬虫

    模拟访问亚马逊商品的爬虫 AmazonRobot 是通过 python 实现的一个通过脚本自动访问Amazon上的商品的爬虫程序.主要实现了用户注册.根据给出的搜索词语和商品的 asin 号进行搜索并 ...

  8. 亚马逊SP-API对接实践解析(amazon selling partner api)

    1.前言 亚马逊(amazon)在2020年10月推出了新的替代MWS的api方案,称为Selling Partner API(SP-API). SP-API在授权方式.权限管理.覆盖站点.支持的卖家 ...

  9. 亚马逊云科技发布五项Amazon QuickSight全新功能简化BI运营

    2022年12月13日,亚马逊云科技在2022 re:Invent全球大会上发布五项Amazon Quicksight全新功能,帮助客户简化BI(商业智能)运营.Amazon Quicksight是云 ...

最新文章

  1. fwrite ,fprintf的作用与区别
  2. springMVC注解@initbinder日期类型的属性自动转换
  3. IOS设计模式之四(备忘录模式,命令模式)
  4. 不到三千买iPhone12 网友:抢到算我输
  5. Rust语言学习大纲
  6. 关于对DataTable进行操作的几个例子总结
  7. WIN10平板 如何关闭自动更新
  8. 惠普win7驱动_hp打印机驱动如何安装 hp打印机驱动安装方法【步骤详解】
  9. 华为数通HCIA笔记(OSI七层)
  10. 【渝粤教育】电大中专消费者行为学_1作业 题库
  11. java注册功能实现
  12. 专网网速测试软件,CMD怎么测试网速?测网速用命令PING
  13. Unity用代码写一个Inspector里面能拉动的滑条
  14. php粒子背景特效_12个精致炫酷的背景装饰特效库(分享)
  15. 网络名称以太网网络2/3修改成网络
  16. python dynamic
  17. [UVALive3942] Remember the Word 字符串
  18. tx2 opense
  19. 认准魔趣吧唯一网址https://www.moqu8.com,谨防上当受骗!
  20. 多商户商城系统功能拆解34讲-平台端营销-足迹气泡

热门文章

  1. qt 多个模型如何显示在表格中_Qt MOOC系列教程 第五章第四节:QML中的C++模型
  2. provide和inject,Vue父组件直接给孙子组件传值
  3. mpvue 转uniapp 导航栏样式错乱问题修复 tabbar 样式修复
  4. centos 7 部署k8s集群
  5. Word文档使用密码加密
  6. 化敌为友 运营商组团拥抱OTT为哪般
  7. VS2005编译QT4.8.2
  8. 2016/08/27 What I Learned About Going Fast at eBay and Google
  9. 開始Unity3D的学习之旅
  10. Widgets 整理