我在使用Facebook Comments社交插件,我希望每次有人添加新評論時都能發送電子郵件。在過去,我使用Rails的Action Mailer發送郵件,但我無法弄清楚如何讓它工作。如何使用JavaScript通過Rails 3 Action Mailer發送電子郵件?
我在聽的JavaScript事件FB.Event.subscribe('comment.create)
然後我想要的回調函數來發送Ajax請求的ActionMailer發送一封電子郵件。我該怎麼做呢?
JavaScript代碼:
FB.Event.subscribe('comment.create', commentMailer(response))
function commentMailer(response) {
//code to call function to send mail
}
Rails代碼:
class UserMailer < ActionMailer::Base
default :from => "<email address>"
def new_comment_email(user, ride)
@user = user
@ride = ride
emails = ride.users.collect {|user| user.email}
mail(:to => emails, :subject => "etc")
end
end
檢查[this](http://phpjs.org/functions/mail:884)out。 – Purag 2011-12-19 23:20:27
@Purmou,你對他的問題的回答是一個可疑的PHP函數? – 2011-12-19 23:23:40
@SrdjanPejic:不,它是到PHP.js郵件功能的鏈接。 PHP.js讓你在Javascript中使用PHP函數。 – Purag 2011-12-19 23:24:15