amazon-web-services - AWS SES 在本地计算机上运行
问题描述
我编写了一个使用 aws ses 发送电子邮件的系统(代码如下)。这在网站上运行良好,但我也很惊讶它似乎可以在我的本地计算机上运行。我想知道的是,如果我不小心为我的 aws 帐户提供了全球发送电子邮件的能力,或者我的本地电脑是否以某种方式登录到 aws,以便它仍然可以发送电子邮件。如果是这种情况,我如何注销以确保它是安全的?或者我如何确保它只是可以发送电子邮件的网站。
谢谢
标记
# Form is valid, get the data from the form
sender_email = form.cleaned_data['form_email']
# Generate the new email message
strNewSubject = "CONTACT FROM sendemail DJANGO APP"
strNewMessage = f"Hello from a random user of sendemail Django App."
# Create a new SES resource and specify a region. SES is in
# eu-west-1 NOT eu-west-2
client = boto3.client('ses', region_name="eu-west-1")
tmpDestination = {'ToAddresses':
["blah@something.com", ], }
tmpMessage = {
'Body': {
'Text': {
'Charset': "UTF-8",
'Data': strNewMessage,
},
},
'Subject': {
'Charset': "UTF-8",
'Data': strNewSubject,
},
}
# Provide the contents of the email.
response = client.send_email(
Destination=tmpDestination,
Message=tmpMessage,
Source="srcaddress@gmail.com"
)
# Email sent and no error's
return True
解决方案
这只是一些额外的点,可能会帮助将来有这种担忧的人,它扩展了 jordanm 的答案,这非常有帮助:
您可以使用以下方法获取当前可用配置文件的列表:
aws configure list-profiles
您可以使用以下方法列出您当前的个人资料:
aws configure list
您可以使用以下方法获取有关特定配置文件的信息:
aws configure list --profile profile_name
假设 .aws 已在您的用户目录 (~) 中设置,您可以使用以下命令查看配置和凭证文件:
cat ~/.aws/config
cat ~/.aws/credentials
然后,您可以使用 --profile 参数或 AWS_PROFILE 环境变量指定您正在使用的配置文件:
aws ec2 describe-volumes --profile dev
export AWS_PROFILE=dev
资料来源:
如何查看 CLI 的默认配置文件?.
https://www.thegeekstuff.com/2019/03/aws-configure-examples/
推荐阅读
- c# - 在没有实现 INotifyPropertyChanged 的情况下更新绑定?
- java - Android 将 AndroidX 库添加到非 android 项目
- python - 在 python 上将 select psql 语句存储到 csv 文件时出错
- python - 如何从另一个脚本获取返回输出?
- autodesk-forge - 如何在 Autodesk Forge Viewer 中更改 ViewCubeUI 的文本?
- html - 我的 CSS 文件已连接并与除 h1 和类 container-fluid 之外的所有元素一起正常工作,我也在使用引导程序
- r - 我正在尝试识别数据框中介于其他两个值之间的相关值
- node.js - 生成 pdf 的 Pupeteer 正在渲染有间隙的表格
- java - 从 HttpServletResponse Java 中获取 responseBody
- woocommerce - 在周末禁用 woocommerce 交付方式并在一周内切断时间