[英]Response from AWS SES with Rails ActionMailer
How do I get message-id from AWS SES when using Rails ActionMailer with :aws_sdk as a delivery method? 将Rails ActionMailer与:aws_sdk用作传递方法时,如何从AWS SES获取消息ID?
config.action_mailer.delivery_method = :aws_sdk
I am only getting the message-id set by ActionMailer, but that gets overwritten by SES: 我只收到由ActionMailer设置的message-id,但是被SES覆盖:
response = ApplicationMailer.create_send(@message).deliver_now
puts response.message_id # => 5a1fbd6417a83_12a406a883740@28b9af04e9b9.mail
How to get the response from SES with actual message-id set by SES? 如何从SES获得由SES设置的实际message-id的响应? I found this Response from SMTP server with Rails , but it didn't work for me.
我从使用Rails的SMTP服务器找到了此响应 ,但对我而言不起作用。
I'm not an expert in ruby but I think the problem is with the AWS library. 我不是红宝石专家,但我认为问题出在AWS库上。 Specifically with the fact that there is no way to set the return_response setting.
特别是没有办法设置return_response设置。
In this file gems/2.3.0/gems/aws-sdk-rails-1.0.1/lib/aws/rails/mailer.rb 在此文件中gems / 2.3.0 / gems / aws-sdk-rails-1.0.1 / lib / aws / rails / mailer.rb
settings is a function hard coded to return an empty hash. settings是一个硬编码为返回空哈希的函数。 And there is no attr_accessor and there is no initialize for it either.
而且没有attr_accessor,也没有初始化。
# ActionMailer expects this method to be present and to return a hash.
def settings
{}
end
And in message.rb there you can get the smtp response code only if delivery_method.settings[:return_response] is true. 在message.rb中,仅当delivery_method.settings [:return_response]为true时,您才能获取smtp响应代码。
# This method bypasses checking perform_deliveries and raise_delivery_errors,
# so use with caution.
#
# It still however fires off the interceptors and calls the observers callbacks if they are defined.
#
# Returns self
def deliver!
inform_interceptors
response = delivery_method.deliver!(self)
inform_observers
delivery_method.settings[:return_response] ? response : self
end
But because settings is not accessible, there is no way to get the response. 但是由于无法访问设置,因此无法获得响应。
So maybe it is possible to use a ruby trick like prepend to override the settings method in the aws library, but for now I'm just adding this line to the aws library file. 因此,也许可以使用诸如prepend之类的ruby技巧来覆盖aws库中的settings方法,但是目前,我只是将此行添加到aws库文件中。
# ActionMailer expects this method to be present and to return a hash.
def settings
{ :return_response => true }
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.