2012-09-23 2 views
0

mailcatcher을 사용하여 메일이 전송되었는지 확인하고 싶습니다. 그들은 메일러가 생성되어 명확히 호출 되었기 때문에 그 이유가 궁금했습니다. 내 설정/환경/development.rb에 따라서Rails 3에서 mailcatcher 사용

은 내가 쓴 :

OrderMailer.send_new_order(@order).deliver 

그리고 마지막으로이 같은 생성 된 컨트롤러 :

class OrderMailer < ActionMailer::Base 
    default from: "[email protected]" 
    def send_new_order(order) 
    @greeting = "Hi" 
    mail to: "[email protected]", subject: "Test" 
    end 
end 

config.action_mailer.raise_delivery_errors = true 
config.action_mailer.delivery_method = :smtp 
config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 } 

내 전화는 다음과 같습니다

물론 mailcatcher가 실행됩니다. 그렇다면 왜 메일을 보내지 않았습니까?

답변

12

나는 개발 환경에 잘못된 SMTP 주소를 사용한다는 것을 알았다.

그것은

config.action_mailer.smtp_settings = { :address => "127.0.0.1", :port => 1025 } 

대신 이것에 대한 이유가

config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 } 
+0

될했다? 127.0.0.1 동안 localhost가 작동하지 않는 이유는 무엇입니까? –

+0

@AnonJ 방금 ip 또는 url을 예상 했으므로 localhost가 아무 것도 해결하지 못했을 것입니다. 어쩌면 http : // localhost가 작동했을 것입니다. 나중에 이것을 확인하겠습니다. –

관련 문제