微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

AWS SES 在本地计算机上运行

如何解决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

来源:
How to see what profile is default with CLI?
https://www.thegeekstuff.com/2019/03/aws-configure-examples/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。