1

Rails ActionMailer와 함께 aws_sdk를 전달 방법으로 사용할 때 AWS SES에서 message-id를 얻으려면 어떻게해야합니까?AWS SES with Rails ActionMailer

config.action_mailer.delivery_method = :aws_sdk 

난 단지 ActionMailer가 설정 한 메시지 ID를 얻고 있지만, 그 SES 덮어 쓰기됩니다 :

response = ApplicationMailer.create_send(@message).deliver_now 
puts response.message_id # => [email protected] 

어떻게 SES가 설정 한 실제 메시지 ID와 SES의 응답을 얻기 위해? 이 Response from SMTP server with Rails을 찾았지만 나에게 도움이되지 못했습니다.

+0

나는 사용하여 https://stackoverflow.com/questions/6374648/actionmailer-smtp-server-response처럼,'순 :: SMTP :: Response'를 사용하여 응답을 얻을 수 있어요 : 같은 SMTP 배달 방법 및 응답 응답 설정 : true. 이것이 가장 선택적 솔루션은 아니지만. – ZeroEnna

답변

0

저는 Ruby 전문가는 아니지만 문제는 AWS 라이브러리에 있다고 생각합니다. 특히 return_response 설정을 설정할 방법이 없다는 점에서 특히 그렇습니다. 이 파일 보석/2.3.0/보석/AWS-SDK-레일-1.0.1/lib 디렉토리/AWS/레일/mailer.rb

설정에서

하드 빈 해시를 반환하도록 코딩 기능입니다 . 그리고 attr_accessor가없고 초기화도 없습니다. [: return_response] 사실이다
# ActionMailer expects this method to be present and to return a hash. 
    def settings 
    {} 
    end 

그리고 message.rb에

이 당신 delivery_method.settings이 경우에만 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 

설정에 액세스 할 수 없기 때문에 응답을받을 수있는 방법이 없습니다.

aws 라이브러리의 설정 메소드를 덮어 쓰려면 prepend와 같은 루비 트릭을 사용할 수도 있지만, 지금은 aws 라이브러리 파일에이 라인을 추가하는 것입니다.

# ActionMailer expects this method to be present and to return a hash. 
    def settings 
    { :return_response => true } 
    end