0

我知道使用 Mandrill 语法,我可以通过执行以下操作发送用户特定信息:

def confirmation_instructions(record, token, opts={})
  options = {
    :subject => 'Email confirmation',
    :email => record.email,
    :name => record.first_name,
    :global_merge_vars => [
      {
        name: 'email',
        content: record.email
      },
      {
        name: 'confirmation_link',
        content: record.confirmation_token
      }
    ],
    :template => 'confirm_email'
  }
  mandrill_send(options)
end

但是如何发送设计确认说明 html.erb 中的实际确认链接?

意见/confirmable/mailer/confirmation_instructions.html.erb

<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>

更新

我编辑了,所以我发送了这个链接:

content: 'http://localhost:3000/users/confirmation?confirmation_token=' + record.confirmation_token

我认为它仍然不起作用,因为令牌实际上是加密的。我认为是这种情况,因为当我使用默认邮件程序时,令牌比我从 record.confirmation_token 获得的令牌短得多。

有人可以让我知道如何将正确的令牌传递给 Mandrill 吗?

4

1 回答 1

0

我有同样的问题,对我有用的是使用'token'而不是'record.confirmation_token'。似乎 Devise 的最新更新改变了一些 Mailer 的方法配置。

而不是: http : //domain.com/users/confirmation?confirmation_token='+record.confirmation_token

使用: http ://domain.com/users/confirmation?confirmation_token ='+token

让我知道它是否对您有帮助。

于 2014-11-28T03:43:07.663 回答