2013-12-07 3 views
0

시스템에 몇 가지 다른 메일러 설정이 있습니다. 하나는 잘 작동하고 다른 하나는 오류가 없지만 이메일을 발송하지는 않습니다.오류가 없어도 Actionmailer는 전자 메일을 보내지 않습니다.

작동하는 우편물은 다음과 같습니다

class UserMailer < ActionMailer::Base 
    default from: "[email protected]" 

    # Subject can be set in your I18n file at config/locales/en.yml 
    # with the following lookup: 
    # 
    # en.user_mailer.password_reset.subject 
    # 
    def password_reset(user) 
    @user = user 
    mail to: user.email, subject: "Password Reset" 
    end 

    def confirm_registration(user) 
    @user = user 
    mail to: user.email, subject: "Confirm Registration" 
    end 
end 

을하고 나는 로그에 다음과 같은 얻을 password_reset 이메일 보낼 때 : 또한

Started POST "/password_resets" for 127.0.0.1 at 2013-12-06 17:24:32 -0600 
Processing by PasswordResetsController#create as HTML 
    Parameters: {"utf8"=>"✓", "authenticity_token"=>"jwGUtsyNRbCfBRFJm3uqcVZA4luHc05Gf0OBm4jyFpI=", "email"=>"[email protected]", "commit"=>"Reset Password"} 
    [1m[35mUser Load (0.8ms)[0m SELECT "users".* FROM "users" WHERE "users"."email" = '[email protected]' LIMIT 1 
    [1m[36m (0.2ms)[0m [1mBEGIN[0m 
    [1m[35mSQL (2.7ms)[0m UPDATE "users" SET "password_reset_token" = $1, "updated_at" = $2 WHERE "users"."id" = 2 [["password_reset_token", "c851e80faeb3612c654c512857cfb29afc6a4665"], ["updated_at", Fri, 06 Dec 2013 23:24:32 UTC +00:00]] 
    [1m[36m (5.8ms)[0m [1mCOMMIT[0m 
    [1m[35m (1.2ms)[0m BEGIN 
    [1m[36mSQL (1.5ms)[0m [1mUPDATE "users" SET "password_reset_sent_at" = $1, "updated_at" = $2 WHERE "users"."id" = 2[0m [["password_reset_sent_at", Fri, 06 Dec 2013 23:24:32 UTC +00:00], ["updated_at", Fri, 06 Dec 2013 23:24:32 UTC +00:00]] 
    [1m[35m (1.6ms)[0m COMMIT 
    Rendered user_mailer/password_reset.text.erb (2.3ms) 

Sent mail to [email protected] (316.8ms) 
Date: Fri, 06 Dec 2013 17:24:32 -0600 
From: [email protected] 
To: [email protected] 
Message-ID: <[email protected]> 
Subject: Password Reset 
Mime-Version: 1.0 
Content-Type: text/plain; 
charset=UTF-8 
Content-Transfer-Encoding: 7bit 

To reset your password, click the URL below. 

http://localhost:3000/password_resets/c851e80faeb3612c654c512857cfb29afc6a4665/edit 

If you did not request your password to be reset, just ignore this email and 
your password will continue to stay the same. 

Redirected to http://localhost:3000/ 
Completed 302 Found in 380ms (ActiveRecord: 13.7ms) 

을, 메시지의보기는 다음과 같이 정의된다 password_reset.text.erb이며 app/views/user_mailer에 있으며 다음과 같이 표시됩니다.

class PoolMailer < ActionMailer::Base 
    default from: "[email protected]" 

    def send_pool_message(pool, subject, msg, allMembers) 
    @pool = pool 
    @msg = msg 
    email_list = Array.new 
    @pool.users.each do |user| 
     if allMembers 
     entries = Entry.where(user_id: user.id) 
     else 
     entries = Entry.where(pool_id: pool.id, user_id: user.id, survivorStatusIn:true) 
     end 
     if entries.any? 
     email_list << "#{user.name} <#{user.email}>" 
     end 
    end 
    subject_text = pool.name + ": " + subject 
    if mail to: email_list, subject: subject_text 
     puts "Successfully sent email" 
     return false 
    else 
     puts "Couldn't send email" 
     return true 
    end 
    end 
end 

을 그리고 로그는 다음과 같습니다 : 작동하지 않습니다메일러는 다음과 같습니다

Started POST "/pools/2/pool_messages" for 127.0.0.1 at 2013-12-06 17:50:54 -0600 
Processing by PoolMessagesController#create as HTML 
    Parameters: {"utf8"=>"✓", "authenticity_token"=>"jwGUtsyNRbCfBRFJm3uqcVZA4luHc05Gf0OBm4jyFpI=", "subject"=>"This is a test", "msg"=>"A test of the group pool message.", "allMembers"=>"false", "commit"=>"Send email", "pool_id"=>"2"} 
    [1m[36mPool Load (8.9ms)[0m [1mSELECT "pools".* FROM "pools" WHERE "pools"."id" = $1 LIMIT 1[0m [["id", "2"]] 
    [1m[35mUser Load (0.7ms)[0m SELECT "users".* FROM "users" INNER JOIN "pool_memberships" ON "users"."id" = "pool_memberships"."user_id" WHERE "pool_memberships"."pool_id" = $1 [["pool_id", 2]] 
    [1m[36m (0.4ms)[0m [1mSELECT COUNT(*) FROM "entries" WHERE "entries"."user_id" = 2[0m 
    [1m[35m (0.3ms)[0m SELECT COUNT(*) FROM "entries" WHERE "entries"."user_id" = 3 
    [1m[36m (0.3ms)[0m [1mSELECT COUNT(*) FROM "entries" WHERE "entries"."user_id" = 4[0m 
    [1m[35m (0.4ms)[0m SELECT COUNT(*) FROM "entries" WHERE "entries"."user_id" = 5 
    Rendered pool_mailer/send_pool_message.text.erb (0.7ms) 
Redirected to http://localhost:3000/pools/2 
Completed 302 Found in 1527ms (ActiveRecord: 11.0ms) 

그리고이 메일에 대한보기 것은이라고 send_pool_message.text.erb 및 위치 app/views/pool_mailer에서 다음과 같이 표시됩니다.

<%= @msg %> 

This is an automated email sent by the pool administer. Do not reply to this 
email. 

첫 번째 메일러가 올바르게 이메일을 보내고 기록합니다. 두 번째 메일러는 전자 메일을 보내지도 전자 메일도 기록하지 않습니다. 나는이 문제에 대해 절대적으로 오류 메시지가 전혀 없기 때문에 문제를 바로 잡을 곳을 모르겠습니다.

이 문제를 해결할 수있는 올바른 방향을 알려주는 도움을 주시면 대단히 감사하겠습니다.

+0

포스트 컨트롤러 액션을 제공하지 않고 이메일을 생성 Otherwiser

을 제공 메일러 기능. – zeantsoi

답변

1

당신은 당신의 메일 발송 기능

PoolMailer.send_pool_message (...)에 .deliver 호출해야합니다. 그냥 호출이

+0

이것은 아마도 대답이 아닙니다. OP는 메일러의 첫 번째 반복이 성공적으로 전송된다고 말합니다. – zeantsoi

+0

내가 이해 한 바에 따르면 그는 첫 번째 메일러 (UserMailer)가 아닌 첫 번째 유형에 대해 이야기하고 있습니다 –

+0

@ Marc-AlexandreBérubé 도움을 주셔서 감사합니다! 나는 명백한 문제를 완전히 놓친 메일러 항목을 모두 보면서 너무 바빴다! –

관련 문제