我尝试使用新的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 = '[email protected]'
config.domain = 'localhost'
end
mailer.rb
def send_unsubscribe(user)
@user = user
@to = "[email protected]"
@from = "[email protected]"
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中没有电子邮件...
似乎您正在寻找使用Mailjet的SMTP中继。这是如何以这种方式配置它:
首先,将该行更改config.domain = 'localhost'
为您的注册域名,而不只是“ localhost”。
接下来,将此添加config.action_mailer.delivery_method = :mailjet_smtp
到您的application.rb文件
不能完全确定您使用的是哪种托管服务,但请查看此链接。它显示了如何为每个托管服务配置SPF和DKIM设置以适应Mailjet。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句