即時通訊使用設計和即時通訊嘗試發送一個歡迎電子郵件後,有人註冊使用actionmailer。rails,動作郵件不通過日誌發送說它是
我...
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 => "[email protected]"
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 => "[email protected]",
:password => "example",
:authentication => "plain",
:enable_starttls_auto => true
}
我development.rb我有
...
config.action_mailer.delivery_method = :sendmail
config.action_mailer.perform_deliveries = true
我超難倒爲什麼一直沒有工作。我寫了一個較老的項目,並且我得到了動作郵件工作。現在的代碼幾乎與我的舊項目相同。例外是即時使用設計。
在我的終端窗口,當我運行「軌道的服務器」,在該窗口中,它也說...
Sent mail to [email protected] (140ms)
Date: Thu, 12 Apr 2012 12:32:48 -0700
From: [email protected]
To: [email protected]
Message-ID: <[email protected]>
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永遠不會收到它,它不在我的垃圾郵件中。它可能是設計的郵件/視圖的東西?但即時通訊在控制器中明確使用UserMailer,這就是爲什麼我重寫它
我一直堅持了幾天!幫助將不勝感激。多謝
令人難以置信。我真的以爲我試圖改變它爲smtp。我一定是在別的地方做過的。它也適用於不配置它,因爲我猜它默認爲smtp(至少根據我如何設置它)。非常感謝你。我非常感謝它! – Sasha 2012-04-13 01:05:12