모든 종류의 구성을 시도했지만 여전히 레일에서 내 개발 환경의 전자 메일을 보낼 수 없습니다.레일스 3 메일러가 작동하지 않고 오류가 기록되지 않습니다.
나는 명령 행에서 이것을 시험해보기 위해 mailutils를 설치했고 효과가 있었다. 나는 스팸 메일을 받았다. echo test |
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = true # still no logs about emails
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true # I can't believe I have to add this option. Does it even exist? I found it on google.
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:authentication => :login,
:user_name => "[email protected]",
:password => "abc123",
}
그리고 여기 메일러의 코드입니다 :
class UserMailer < ActionMailer::Base
default :from => "[email protected]"
def test_email
Rails.logger.debug 'test_email'
mail(:to => '[email protected]', :subject => "testing rails")
end
end
컨트롤러는 :
class PagesController < ApplicationController
def home
UserMailer.test_email
end
end
개발 메일
가 여기 내 설정의 주제 [email protected]에게 -s .log :
[2012-03-01 18:26:45.859] DEBUG [bb44dee806d73eb60ab3ae16297f5c02] [127.0.0.1] [GET] [http://myapp:3000/] test_email
[2012-03-01 18:26:45.888] INFO [bb44dee806d73eb60ab3ae16297f5c02] [127.0.0.1] [GET] [http://myapp:3000/] Rendered user_mailer/test_email (1.6ms)
[2012-03-01 18:26:45.898] INFO [bb44dee806d73eb60ab3ae16297f5c02] [127.0.0.1] [GET] [http://myapp:3000/] Rendered pages/home.html.erb within layouts/application (1.1ms)
[2012-03-01 18:26:46.815] INFO [bb44dee806d73eb60ab3ae16297f5c02] [127.0.0.1] [GET] [http://myapp:3000/] Completed 200 OK in 455ms (Views: 112.4ms)
는 또한 콘솔을 사용하여 시도 : 도메인 :
당신이 설정입니다 의심되는 경우[email protected]:/srv/www/myapp# rails c
Loading development environment (Rails 3.2.1)
irb(main):001:0> UserMailer.test_email
=> #<Mail::Message:32110400, Multipart: false, Headers: <To: [email protected]>, <Subject: testing rails>, <Mime-Version: 1.0>, <Content-Type: text/html>>
http://guides.rubyonrails.org/action_mailer_basics.html에는 GMail 구성에 대한 예제가 있습니다. 그것은 인증 특성에 'plain'을 사용합니다. 시도해 보셨습니까? – ismriv
예. 시도했지만 아무 일도 없었습니다. 로그가 없으면 이것이 효과가 없을 것입니다. 요청의 다른 모든 항목이 올바르게 기록됩니다. – HappyDeveloper
메일러를 호출하는 코드는 어떻게 생겼습니까? –