【问题标题】:Rails : Send email with Mailjet Api V3Rails:使用 Mailjet Api V3 发送电子邮件
【发布时间】:2014-08-09 00:39:00
【问题描述】:

我尝试使用新的 mailjet api (v3) 发送电子邮件。 这是我的配置:

宝石文件

宝石'mailjet'

config/initializers/mailjet.rb

Mailjet.configure do |config|
  config.api_key = '<my api>'
  config.secret_key = '<my_psw>'
  config.default_from = 'mail@conicrea.com'
  config.domain = 'localhost'
end

ma​​iler.rb

  def send_unsubscribe(user)
    @user = user
    @to = "paul@conicrea.com"
    @from = "mail@conicrea.com"

    mail(to: @to, from: @from, subject: "TTP Tork - Demande de désinscription") do |format|
      format.html
    end
  end

user.rb

def send_unsubscribe
  Mailer.send_unsubscribe(self).deliver
end

u.send_unsubscribe

在日志中,邮件似乎是创建并发送,但我的邮箱和 mailjet 中没有电子邮件...

【问题讨论】:

    标签: ruby-on-rails ruby email mailjet


    【解决方案1】:

    您似乎希望使用 Mailjet 的 SMTP 中继。以下是如何配置它:

    首先将这一行 config.domain = 'localhost' 更改为您的注册域名,而不仅仅是“localhost”。

    接下来,将此config.action_mailer.delivery_method = :mailjet_smtp 添加到您的 application.rb 文件中

    不完全确定您使用的是哪种托管服务,但请查看this link。它向您展示了如何为每个托管服务配置 SPF 和 DKIM 设置以适应 Mailjet。

    【讨论】:

      猜你喜欢
      • 2020-08-29
      • 2012-11-01
      • 1970-01-01
      • 2016-08-01
      • 1970-01-01
      • 2022-10-22
      • 1970-01-01
      • 1970-01-01
      • 2015-08-26
      相关资源
      最近更新 更多