简体   繁体   中英

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.

We want to sign the emails with 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:

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. We recommend that you check the documentation for your software to find out exactly what headers are signed with 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!

You can take it completely out of your source code and let SES do the DKIM signing for you. Works great.

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 :

https://github.com/jhawthorn/dkim

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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