亚马逊ses如何发qq

SES (Simple Email Service) is, as the name suggests, a very simple service to enable programmatic access to sending and receiving emails. Here is a simple step by step guide to do that in Python — using the Console, AWS CLI, AWS Boto3, as well as a simple Vanila Python script.

顾名思义,SES(简单电子邮件服务)是一种非常简单的服务,可通过编程方式访问发送和接收电子邮件。 这是使用Python进行操作的简单分步指南-使用控制台,AWS CLI,AWS Boto3以及简单的Vanila Python脚本。

Choose the one you like and add it to your own application.

选择您喜欢的一个并将其添加到您自己的应用程序中。

先决条件 (Prerequisites)

Of course, the first and foremost requirement is, an AWS account. If you are reading this blog, I am sure you already have it. If not, please go ahead and create one. It is absolutely required for any developer today.

当然,第一个也是最重要的要求是一个AWS账户。 如果您正在阅读此博客,我相信您已经拥有它。 如果没有,请继续创建一个。 今天,任何开发人员都绝对需要它。

Second, you need an email address — different from Gmail. Google does not like us using AWS to generate mails on its behalf. Those mails usually land in spam, or worse, show an ugly security warning. But if you are doing this only for the test, you should not have a problem with that.

其次,您需要一个电子邮件地址-与Gmail不同。 Google不喜欢我们使用AWS代表它生成邮件。 这些邮件通常以垃圾邮件的形式发送,或更糟糕的是,会显示难看的安全警告。 但是,如果您只是为了测试而这样做,那么您应该不会有任何问题。

Below, I will demonstrate everything using the AWS Web Console, as well as AWS Command Line Interface and the Python Boto3 API. The Web Console does not require any installation. But if you are interested in CLI or Boto3 — I strongly recommend doing that, you should get them installed. Check out these links to do that: CLI, Boto3

下面,我将使用AWS Web Console,AWS Command Line Interface和Python Boto3 API演示一切。 Web控制台不需要任何安装。 但是,如果您对CLI或Boto3感兴趣-我强烈建议您这样做,则应该安装它们。 请查看以下链接以执行此操作: CLI , Boto3

验证电子邮件地址 (Verify Email Addresses)

SES takes all precautions to make sure you do not misuse it to spam others. Before you send an email to or from an account using the AWS, you need to “verify” those email addresses. Let us start with the AWS Console

SES会采取所有预防措施,以确保您不会滥用它来向其他人发送垃圾邮件。 在使用AWS向账户发送电子邮件或从账户发送电子邮件之前,您需要“验证”这些电子邮件地址。 让我们从AWS控制台开始

AWS控制台(AWS Console)

Login to your AWS account from a web browser, and among the list of services, choose the Simple Email Service (SES). Click on that and you will be taken to the SES Home. In the panel on the left, look for Email Addresses. Click on that. There, you will see a button to “Verify a New Email Address”.

从Web浏览器登录到您的AWS账户,然后在服务列表中,选择简单电子邮件服务(SES)。 单击该按钮,您将被带到SES主页。 在左侧面板中,查找“电子邮件地址”。 点击那个。 在那里,您将看到一个“验证新电子邮件地址”按钮。

There you can provide an email ID that you own, and click to Verify. That will generate a simple email to your address. You just have to click a link in that mail and you are done. Similarly, you can verify all the Email ID’s that you want to. When you refresh the page, you will see those Email ID’s in the list.

您可以在此处提供您拥有的电子邮件ID,然后单击“验证”。 这将生成一封简单的电子邮件到您的地址。 您只需要单击该邮件中的链接即可。 同样,您可以验证所需的所有电子邮件ID。 刷新页面时,您将在列表中看到那些电子邮件ID。

AWS CLI (AWS CLI)

On the CLI, things are absolutely simple. You just need to run a single command and that completes the task for you.

在CLI上,事情绝对简单。 您只需要运行一个命令即可为您完成任务。

aws ses verify-email-identity --email-address name@domain.com

That is all, it will generate the verification mail to your email id and you can click the link to complete the process.

就是这样,它将生成验证邮件到您的电子邮件ID,您可以单击链接来完成该过程。

Boto3 (Boto3)

You can also do it in Python — using the Boto3

您也可以在Python中使用Boto3

import boto3
client = boto3.client('ses')
response = client.verify_email_identity(EmailAddress='name@domain.com'
)

Simple again. You create an SES client and invoke the verify_email_identity() method on it. It will generate the same email that can allow you to click a link and verify the email account.

再次简单。 您创建一个SES客户端,并在其上调用verify_email_identity()方法。 它将生成相同的电子邮件,使您可以单击链接并验证电子邮件帐户。

发送电子邮件 (Send Email)

Now sending an email is simple on either of these interfaces. If you like the Web UI you can do it on the Console, else you can do it on the CLI and also on Boto3.

现在,在这两个界面中的任何一个上发送电子邮件都很简单。 如果您喜欢Web UI,则可以在控制台上进行操作,否则可以在CLI和Boto3上进行操作。

AWS ensures that you do not misuse the service to generate spam. For this, you are not allowed to generate an email to or from an address that you have not yet verified as your own. You can raise a request to Exit Sandbox. If this is approved, you will be able to send to any Email ID. But, the From is always restricted to the one you have verified.

AWS确保您不会滥用服务生成垃圾邮件。 为此,不允许您向尚未验证为自己的地址生成电子邮件或从该地址生成电子邮件。 您可以提出退出“沙箱”的请求。 如果这被批准,您将能够发送到任何电子邮件ID。 但是,“发件人”始终仅限于您已验证的发件人。

The From address is frozen — the one you had selected. You can specify your To address. If you have not requested AWS in the SES Sandbox

发件人地址已冻结-您选择的地址。 您可以指定您的收件人地址。 如果您尚未在SES沙箱中请求AWS

AWS控制台 (AWS Console)

On the same page in the AWS Console, Email Addresses, select any email address from the list.

在AWS控制台的同一页面上,电子邮件地址,从列表中选择任何电子邮件地址。

When you select it, a button is enabled — to send a test mail. When you click on that, it will open a modal — that allows you to draft your mail.

选择它后,将启用一个按钮-发送测试邮件。 当您单击它时,它将打开一个模式-使您可以起草邮件。

The From address is not editable — it is the one you chose when you clicked the Sent mail button. You can choose the To address. But again, it has to be within the constraints of SES.

“发件人”地址不可编辑-这是单击“已发送邮件”按钮时选择的地址。 您可以选择“收件人”地址。 但同样,它必须在SES的限制之内。

SES allows two formats for sending mails — Raw and Formatted. Formatted is the simplest. You just fill in the required details in each field and click send. That is all. The email is sent!

SES允许两种格式发送邮件-Raw和Formatted。 格式化是最简单的。 您只需在每个字段中填写所需的详细信息,然后单击发送。 就这些。 电子邮件已发送!

AWS CLI (AWS CLI)

Sending an email from the CLI is just a line of code. All you need is the base command with a chunk of options.

从CLI发送电子邮件只是一行代码。 您需要的只是带有大量选项的基本命令。

aws ses send-email --from sender@domain.com --to receiver@domain.com --text "This is for those who cannot read HTML." --html "<h1>Hello World</h1><p>This is a pretty mail with HTML formatting</p>" --subject "Hello World"

You can have a more complex message text or also specify an HTML message by using the appropriate parameters.

您可以使用更复杂的消息文本,也可以使用适当的参数指定HTML消息。

Boto3 (Boto3)

A Python script can also use the Boto3 to send a similar email. You just need to create an SES client and invoke the appropriate method.

Python脚本也可以使用Boto3发送类似的电子邮件。 您只需要创建一个SES客户端并调用适当的方法。

import boto3
client = boto3.client('ses')
response = client.send_email(Destination={'ToAddresses': ['receiver@domain.com'],},Message={'Body': {'Html': {'Charset': 'UTF-8','Data': '<h1>Hello World</h1><p>This is a pretty mail with HTML formatting</p>',},'Text': {'Charset': 'UTF-8','Data': 'This is for those who cannot read HTML.',},},'Subject': {'Charset': 'UTF-8','Data': 'Hello World',},},Source='sender@domain.com',
)

原始邮件(Raw Mail)

In the above examples, we saw some very basic emails. These can be useful — perhaps for some auto-generated notification mails. But in real life, we need a lot more than that.

在以上示例中,我们看到了一些非常基本的电子邮件。 这些可能很有用-也许对于某些自动生成的通知邮件。 但是在现实生活中,我们不仅需要更多。

For this, we use the Raw mails. Here, we can specify and configure a lot details, that can be required while sending an email. If you want real code, you should get into the habit of using the Raw mails and nothing else.

为此,我们使用原始邮件。 在这里,我们可以指定和配置很多详细信息,这在发送电子邮件时可能是必需的。 如果您想要真正的代码,则应该养成使用Raw邮件的习惯,而别无其他。

Here is a sample code for sending a raw mail.

这是发送原始邮件的示例代码。

import os
import boto3
from botocore.exceptions import ClientError
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
# Setup the basics here
SENDER = "Sender Name <sender@domain.com>"
RECIPIENT = "recipient@domain.com"
SUBJECT = "Customer service contact info"
# The configuration set used to track mails
CONFIGURATION_SET = "ConfigSet"
# The full path to the file that will be attached to the email.
ATTACHMENT = "path/to/customers-to-contact.xlsx"
# The email body for recipients with non-HTML email clients.
BODY_TEXT = "Hello,\r\nPlease see the attached file for a list of customers to contact."
# The HTML body of the email.
BODY_HTML = """\
<html>
<head></head>
<body>
<h1>Hello!</h1>
<p>Please see the attached file for a list of customers to contact.</p>
</body>
</html>
"""
# The character encoding for the email.
CHARSET = "utf-8"
# Create a new SES resource and specify a region.
client = boto3.client('ses')
# Create an instance of multipart/mixed parent container.
msg = MIMEMultipart('mixed')
# Add subject, from and to lines.
msg['Subject'] = SUBJECT
msg['From'] = SENDER
msg['To'] = RECIPIENT
# Create a multipart/alternative child container.
msg_body = MIMEMultipart('alternative')
# Encode the text and HTML content and set the character encoding. This step is
# necessary if you're sending a message with characters outside the ASCII range.
textpart = MIMEText(BODY_TEXT.encode(CHARSET), 'plain', CHARSET)
htmlpart = MIMEText(BODY_HTML.encode(CHARSET), 'html', CHARSET)
# Add the text and HTML parts to the child container.
msg_body.attach(textpart)
msg_body.attach(htmlpart)
# Define the attachment part and encode it using MIMEApplication.
att = MIMEApplication(open(ATTACHMENT, 'rb').read())
# Add a header to tell the email client to treat this part as an attachment,
# and to give the attachment a name.
att.add_header('Content-Disposition','attachment',filename=os.path.basename(ATTACHMENT))
# Attach the multipart/alternative child container to the multipart/mixed
# parent container.
msg.attach(msg_body)
# Add the attachment to the parent container.
msg.attach(att)
#print(msg)
try:#Provide the contents of the email.response = client.send_raw_email(Source=SENDER,Destinations=[RECIPIENT],RawMessage={'Data':msg.as_string(),},ConfigurationSetName=CONFIGURATION_SET)
# Display an error if something goes wrong.
except ClientError as e:print(e.response['Error']['Message'])
else:print("Email sent! Message ID:"),print(response['MessageId'])

Essentially, it instantiates an object msg, and populates all the relevant fields. Finally this is passed into the send_raw_email() method, that actually sends the mail.

本质上,它实例化一个对象msg,并填充所有相关字段。 最后,将其传递到send_raw_email()方法中,该方法实际发送邮件。

SMTP (SMTP)

Well, all that was bound within the boundaries of AWS. We can also go out of AWS limits and still use this service. SES also provides us a simple SMTP interface to send emails using the SES.

好吧,所有这些都被限制在AWS的范围之内。 我们还可以超出AWS限制,仍然使用此服务。 SES还为我们提供了一个简单的SMTP界面,以使用SES发送电子邮件。

This is simple to configure. On the SES console, click on the SMTP settings on the left panel. That will take you to the SMTP configuration page. Click on the button to create your SMTP user and password. The SMTP credentials that it creates, are simply an IAM user — with specific permissions to invoke email requests.

这很容易配置。 在SES控制台上,单击左侧面板上的SMTP设置。 这将带您进入SMTP配置页面。 单击按钮创建您的SMTP用户和密码。 它创建的SMTP凭据只是一个IAM用户-具有调用电子邮件请求的特定权限。

With the user credentials, you can run the below script to send out simple emails.

使用用户凭据,您可以运行以下脚本来发送简单的电子邮件。

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib
smtphost = "email-smtp.us-east-1.amazonaws.com"
# Get the user name and password - from the IAM user that is created by SES.
password = "BFSNXwvnfnBHmz+dqPAXWgYeH3sfdsgvfxKbiUR6NvD7oW"
username = "AKIA4VCC4EEK5EXQOWEFGML"
message = "Test from Python via AuthSMTP"
msg = MIMEMultipart()
msg['From'] = "sender@domain.com"
msg['To'] = "receiver@domain.com"
msg['Subject'] = "Test from Python via AuthSMTP"
msg.attach(MIMEText(message, 'plain'))
server = smtplib.SMTP(smtphost)
server.starttls()
server.login(username, password)
server.sendmail(msg['From'], msg['To'], msg.as_string())
server.quit()

The SMTP server is only a convenience utility provided by AWS. Internally, it just maps an incoming SMTP request into the corresponding SES request and then processes it.

SMTP服务器只是AWS提供的便利工具。 在内部,它只是将传入的SMTP请求映射到相应的SES请求中,然后对其进行处理。

There are several feature rich open source SMTP servers, that you can use to create emails with all the functionality you like. Invoking the SMTP send is absolutely simple, and it can be done using your code running anywhere — not restricted to running within AWS.

有几种功能丰富的开源SMTP服务器,可用于创建具有所有所需功能的电子邮件。 调用SMTP发送非常简单,并且可以使用可在任何地方运行的代码来完成它-不限于在AWS中运行。

Original: https://thewiz.net/aws_ses_to_send_emails__38d1.html

原文: https : //thewiz.net/aws_ses_to_send_emails__38d1.html

翻译自: https://medium.com/@vikassolegaonkar/amazon-ses-to-send-emails-58997d932871

亚马逊ses如何发qq

http://www.taodudu.cc/news/show-3238787.html

相关文章:

  • 亚马逊html添加特殊符号,亚马逊SES中的特殊字符
  • 用SEGGER Embedded Studio(SES)开发蓝牙nRF52840
  • 关于SES2000定位数据后修正的过程说明
  • amazon ses_Amazon Simple Email Service(SES)入门
  • 通海井安装SES2000管线仪
  • SAS之SCSI Enclosure Services - 3 (SES-3)
  • ses控制硬盘指示灯亮灭
  • nRF52832:使用 SEGGER Embedded Studio(SES)创建库文件
  • 邮件、短信验证码和邮箱认证服务方案选型全指南
  • 1.6 如何使用SES搭建SIG MESH开发环境
  • magento|使用亚马逊的ses服务进行邮件营销
  • SES的快速上手
  • 中文自然语言处理stopword下载_chinese_stopword1.txt
  • 二十九天
  • Ftpclient调用retrieveFileStream返回null, docker中下载失败问题
  • 如何统计iOS产品不同渠道的下载量?
  • 如何从微信跳到外部浏览器进行apk文件(app)下载如何解决
  • 微信扫描二维码无法下载app
  • 怎么解决微信不支持下载app(apk/ipa)软件
  • 解决Anaconda3国内资源下载缓慢、下载不了
  • 下载python的步骤ios_python苹果安装教程,ipad上怎么安装python?
  • 微信浏览器禁止app下载链接怎么办怎么解决
  • 仿 IOS 桌面图标下载 view
  • 微信屏蔽app下载链接如何解决
  • Flex中的下载
  • 如何解决微信屏蔽app下载链接
  • 微信扫描二维码无法下载app如何解决
  • 怎么解决微信屏蔽内置浏览器下载功能
  • 微信屏蔽app下载链接
  • 微信不给下载app如何解决

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

  1. 亚马逊ses如何发qq_使用Amazon SES发送电子邮件

    亚马逊ses如何发qq by Kangze Huang 黄康泽 使用Amazon SES发送电子邮件 (Sending emails with Amazon SES) 完整的AWS Web样板-教程3 ...

  2. php发邮件exchange,PHP使用PHPMailer发送电子邮件

    一.PHPMailer 简介 phpMailer 是一个非常强大的 php发送邮件类,可以设定发送邮件地址.回复地址.邮件主题.html网页,上传附件,并且使用起来非常方便.它提供的功能包括: 在发送 ...

  3. 亚马逊html添加特殊符号,亚马逊SES中的特殊字符

    我正在使用适用于PHP的AWS SDK(https://github.com/aws/aws-sdk-php)使用Amazon SES发送电子邮件. 下面的代码:亚马逊SES中的特殊字符 requir ...

  4. 亚马逊kindle设置_在亚马逊Kindle上追逐活跃的社会工程欺诈

    亚马逊kindle设置 TL;DR: I've just spent several hours chasing a socially engineered (not password comprom ...

  5. 亚马逊FBA是什么意思,亚马逊FBA发货操作流程是什么?

    想必跨境行业的从事者都知道,物流是影响消费者体验的重要因素之一,而跨境业务由于是依据各属不同关境的贸易模式,通常发货会需要较长的时间,难以保证货物能在规定的时间内送到买家手里,会很大程度影响卖方口碑, ...

  6. 亚马逊登陆显示服务器出错,亚马逊登录不上去为什么?是因为被封号了吗?

    亚马逊登录不上去,遇到这个问题的卖家们是否感到一丝慌张呢?开店开的好好的,为什么会突然遇到登录不上去的情况呢?本文超级浏览器就来和大家一起整理整理,有哪些原因会导致亚马逊登录不上去的情况,以及卖家们在 ...

  7. 登录亚马逊显示内部服务器出错,亚马逊账号无法登录怎么办?是什么原因导致的?...

    原标题:亚马逊账号无法登录怎么办?是什么原因导致的? 大家在亚马逊开店的过程中是否有遇到账号登录不上的情况呢?亚马逊账号登录不上,如下图, 这是很多卖家会在论坛里问到的问题,很多卖家表示明明自己输入的 ...

  8. 为何亚马逊的员工说,“亚马逊公司该解体了”,到底发生了什么?

    作者 | Jason Del Rey Paul Davis从零开始帮助建立了Amazon . com.现在他说是时候把它拆开了. 戴维斯是一名电脑程序员,他在1994年Jeff Bezos第二次受雇于 ...

  9. 适配器和绑定 没找到_亚马逊如何收款?附亚马逊收款绑定流程

    我做跨境电商也有六年的时间了,在电商这个行业也有自己的一些经验.经验也许没有其他大卖家丰富,但会将我知道的都进行分享.如果有不懂得亚马逊问题可以+我(V:772024802).我这里给大家安排一堂直播 ...

最新文章

  1. Android之app混淆深入分析-层层解析解决开发中痛点
  2. 计算机专业导论论文2000字,计算机专业导论论文.doc
  3. linux系统如何拨号上网连接,教你在Linux下如何使用ADSL拨号上网
  4. ewebeditor未授权:功能被禁用请先配置授权_SteamPY新功能——外区账号礼物自动领取...
  5. 零美术基础逆袭成为动画师!你需要怎么做?
  6. dotnet-cli命令小结
  7. linux 创建进程 execl,linux中进程的vfork()和execl()函数
  8. 【工程项目经验】Compile Android Error fatal error opening dependency file No such file or directory
  9. P2P网络借贷系统-核心功能-用户投标-业务解说
  10. 用Eclipse创建一个spring boot(创建,并配好controller)
  11. C语言程序设计实践-C语言应用实践
  12. JAVA - JDK 1.8 API 帮助文档-中文版
  13. 苏州电信套餐:华为526无线路由猫相关问题
  14. 冲量在线荣获STIF2021国际科创节2021年度技术先锋奖
  15. java 枚举实例化_Java枚举
  16. 基于PHP的教学管理系统_WEB管理系统_MySQL应用
  17. java 转换成大写_java实现将数字转换成人民币大写
  18. 从零开始学统计 03 | 均值,方差,标准差
  19. win2012R2无法打开匿名级安全令牌,安装.net 3.5
  20. 山东淀粉行业面临洗牌,深加工技术资金为王

热门文章

  1. 第十六章、文件服务器之二: SAMBA 服务器
  2. Maven高级5-私服
  3. 水果礼包拼手气(仿红包拼手气)含拼手气红包算法
  4. 积分兑换商城系统有哪些特点
  5. 战疫杯--奇奇怪怪的形状
  6. 7的整除特征 三位一截_能被7整除的数的特征
  7. map.has,map.get,map.set
  8. 什么是服务器?如何租用服务器?
  9. JST日本压着端子GH系列线对板连接器PCB封装库(1.25mm间距)
  10. 前端基础(五)_CSS文本文字属性、背景颜色属性