deviseを使用しているimと、actionmailerを使用してサインアップした後にウェルカムメールを送信しようとしているim。
私はデバイスで登録コントローラーを上書きしました...
def create
build_resource
if resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?
UserMailer.welcome_email(resource).deliver
sign_in(resource_name, resource)
respond_with resource, :location => after_sign_up_path_for(resource)
else
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
expire_session_data_after_sign_in!
respond_with resource, :location => after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
respond_with resource
end
end
その行で
UserMailer.welcome_email(resource).deliver
user_mailer.rbに電話します
default :from => "blink@gmail.com"
def welcome_email(user)
@user = user
@url = "http://example.com/login"
mail(:to => user.email, :submit => "Welcome YEAH!")
end
app / views / user_mailer/welcome_email.text.erbの下にビューがあります
イニシャライザフォルダにsetup_mail.rbがあります
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "blink@gmail.com",
:password => "example",
:authentication => "plain",
:enable_starttls_auto => true
}
私のdevelopment.rbで私は持っています...
config.action_mailer.delivery_method = :sendmail
config.action_mailer.perform_deliveries = true
なぜこれが機能しないのか、私は非常に困惑しています。iveは古いプロジェクトを作成し、アクションメーラーを機能させました。現在のコードは、私の古いプロジェクトとほぼ同じです。例外は、imが現在deviseを使用していることです。
ターミナルウィンドウで「railsserver」を実行すると、そのウィンドウでも次のように表示されます...
Sent mail to blink@gmail.com (140ms)
Date: Thu, 12 Apr 2012 12:32:48 -0700
From: blink@gmail.com
To: blink@gmail.com
Message-ID: <4f872de096f4e_1805f3fdba4834cd493153@spiderman.local.mail>
Subject: Welcome email
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_4f872de0883d4_1805f3fdba4834cd49281a";
charset=UTF-8
Content-Transfer-Encoding: 7bit
submit: Welcome YEAH!
ユーザーがサインアップした後。私はそれが本当に送信するとは思わない。私のGmailはそれを取得することはなく、スパムには含まれていません。それはdeviseのメーラー/ビューで何かでしょうか?しかし、コントローラーでUserMailerを明示的に使用しているので、上書きしました
iveは何日も立ち往生しています!助けていただければ幸いです。本当にありがとう