简体   繁体   English

使用 Amazon SES 对 Rails 应用程序进行 DKIM 签名

[英]DKIM signatures to Rails application using Amazon SES

We're using the ActionMailer with SMTP as our delivery method and Amazon SES as our outgoing mail provider.我们使用 ActionMailer 和 SMTP 作为我们的交付方法,使用 Amazon SES 作为我们的外发邮件提供商。

We want to sign the emails with DKIM.我们想用 DKIM 签署电子邮件。 How can we do that?我们怎么做?

Thanks谢谢

I haven't used DomainKeys Identified Mail (DKIM) via ActionMailer with Amazon SES myself yet, but here's how I'd approach it:我自己还没有通过 ActionMailer 和Amazon SES使用DomainKeys Identified Mail (DKIM) ,但这是我的处理方法:

Note笔记

If you are using the Amazon SES SMTP interface to send email, and your client software automatically performs DKIM signing, you should check to ensure that your client does not sign any of the headers listed above.如果您使用 Amazon SES SMTP 接口发送电子邮件,并且您的客户端软件自动执行 DKIM 签名,您应该检查以确保您的客户端没有对上面列出的任何标头进行签名。 We recommend that you check the documentation for your software to find out exactly what headers are signed with DKIM.我们建议您检查软件的文档,以准确找出哪些标头是用 DKIM 签名的。

# Configure dkim globally (see above)
Dkim::domain      = 'example.com'
Dkim::selector    = 'mail'
Dkim::private_key = open('private.pem').read

# UPDATE [John Hawthorn]: SES developer guide recommends against signing these
Dkim::signable_headers = Dkim::DefaultHeaders - \
    %w{Message-ID Resent-Message-ID Date Return-Path Bounces-To}

# This will sign all ActionMailer deliveries
ActionMailer::Base.register_interceptor('Dkim::Interceptor')

Update更新

John Hawthorn has updated the code fragment with the required SES exceptions (see respectively commented line above), confirming that his apparently excellent dkim gem is indeed If the mentioned SES/DKIM header exception requirements can be met by the dkim gem,this looks like a remarkable easy way to achieve your goal - thanks John! John Hawthorn 已使用所需的 SES 异常更新了代码片段(参见上面分别注释的行),确认他显然出色的 dkim gem 确实是 如果 dkim gem 可以满足 提到的 SES/DKIM 标头异常要求,这看起来像 实现目标的非凡简单方法 - 谢谢约翰!

You can take it completely out of your source code and let SES do the DKIM signing for you.您可以将其完全从源代码中取出,让 SES 为您进行 DKIM 签名。 Works great.效果很好。

https://aws.amazon.com/blogs/aws/simple-email-service-easy-domainkeys-identified-mail-support/ https://aws.amazon.com/blogs/aws/simple-email-service-easy-domainkeys-identified-mail-support/

You can use the dkim project to do that for you :您可以使用 dkim 项目为您做到这一点:

https://github.com/jhawthorn/dkim https://github.com/jhawthorn/dkim

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM