jhawthorn/dkim — Issue #6: Duplicate DKIM header
Author: cmer
Created: 2012-01-27 19:59:03+00:00
State: open

Hi,

I'm using your gem in a Rails 3.2 app to send emails through Amazon SES. Here's my config:

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

# Required for SES
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')

The problem I'm having is that every message I send fails because of this error:

| {554 Transaction failed: Duplicate header 'DKIM-Signature'.

/home/deploy/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/net/smtp.rb:948:in `check_response'
/home/deploy/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/net/smtp.rb:902:in `data'
/home/deploy/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/net/smtp.rb:660:in `block in send_message'
/home/deploy/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/net/smtp.rb:849:in `rcptto_list'
/home/deploy/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/net/smtp.rb:660:in `send_message'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/mail-2.4.1/lib/mail/network/delivery_methods/smtp.rb:145:in `block in deliver!'
/home/deploy/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/net/smtp.rb:520:in `start'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/mail-2.4.1/lib/mail/network/delivery_methods/smtp.rb:144:in `deliver!'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/mail-2.4.1/lib/mail/message.rb:2033:in `do_delivery'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/mail-2.4.1/lib/mail/message.rb:229:in `block in deliver'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/actionmailer-3.2.0/lib/action_mailer/base.rb:414:in `block in deliver_mail'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.0/lib/active_support/notifications.rb:123:in `block in instrument'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.0/lib/active_support/notifications.rb:123:in `instrument'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/actionmailer-3.2.0/lib/action_mailer/base.rb:412:in `deliver_mail'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/mail-2.4.1/lib/mail/message.rb:229:in `deliver'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/delayed_job-3.0.0/lib/delayed/performable_mailer.rb:6:in `perform'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/delayed_job-3.0.0/lib/delayed/backend/base.rb:94:in `block in invoke_job'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/delayed_job-3.0.0/lib/delayed/lifecycle.rb:60:in `call'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/delayed_job-3.0.0/lib/delayed/lifecycle.rb:60:in `block in initialize'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/delayed_job-3.0.0/lib/delayed/lifecycle.rb:65:in `call'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/delayed_job-3.0.0/lib/delayed/lifecycle.rb:65:in `execute'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/delayed_job-3.0.0/lib/delayed/lifecycle.rb:38:in `run_callbacks'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/delayed_job-3.0.0/lib/delayed/backend/base.rb:91:in `invoke_job'
(eval):3:in `block in invoke_job_with_newrelic_transaction_trace'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/newrelic_rpm-3.3.1/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:255:in `block in perform_action_with_newrelic_trace'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/newrelic_rpm-3.3.1/lib/new_relic/agent/method_tracer.rb:242:in `trace_execution_scoped'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/newrelic_rpm-3.3.1/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:250:in `perform_action_with_newrelic_trace'
(eval):2:in `invoke_job_with_newrelic_transaction_trace'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/delayed_job-3.0.0/lib/delayed/worker.rb:162:in `block (2 levels) in run'
/home/deploy/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/timeout.rb:68:in `timeout'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/delayed_job-3.0.0/lib/delayed/worker.rb:162:in `block in run'
/home/deploy/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
/apps/production/varagesale/shared/bundle/ruby/1.9.1/gems/delayed_job-3.0.0/lib/delayed/worker.r

And my logs confirm it:

Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_4f23006488c2c_7877cfa87897786";
charset=UTF-8
Content-Transfer-Encoding: 7bit
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=varagesale.com; q=dns/txt; s=mail; t=1327693924; bh=VGlBst8LIzltr4xXqcgFHtLmAcKyPiL2C0WKSiWqpI4=; h=content-transfer-encoding:content-type:from:mime-version:subject:to; b=YVipMt36yPhIOQ/GsiF1W6DTODYqmhzQ94KgIMnIQr/ZBDmwgTvIgYCdg7t9iodbLB0E2V0rTSBhcf8/ZIMPoTKgJIsBzdPjWpHj5mfm5GGLk4pAbWvmBVCCWM8g7s6rvWCNRfLAldKbGvSEn9AzF9cNatnXVAOzhbtIHkadLrQ=
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=varagesale.com; q=dns/txt; s=mail; t=1327693935; bh=VGlBst8LIzltr4xXqcgFHtLmAcKyPiL2C0WKSiWqpI4=; h=content-transfer-encoding:content-type:from:mime-version:subject:to; b=ZwAJ8QFbd2bcGFaEVdKq/s/wBUB9hIiEsefJak6yWFPa3tH++fnefWL6z+2QRUhH3vB7ZwqLqZ5oa2+FB9uhQ4QPXnAmXYRGxx6qWopQPkxTojLXskOSCNKvn1ehkeeOEAGwio54eUcmlReGQD8HFQvy+TLDfzT7XiO5D71mmoY=

Any idea what could be causing this?

Thanks!