내 레일 애플리케이션 중 하나에서 이메일을 보내야합니다. 방금 다음과 같이 앱을 구성했습니다.레일에 루비를 사용하여 메일 보내기
레일즈 v2.0을 사용하고 있습니다.
으로 environment.rb :
RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
config.action_controller.session = {
:session_key => '_mailtest_session',
:secret => 'key_here'
}
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 25,
:domain => "gmail.com",
:authentication => :login,
:user_name => "[email protected]",
:password => "password"
}
ActionMailer::Base.default_content_type = "text/html"
end
모델/notifier.rb : 나는이 오류를 받고 있어요 인덱스 메소드를 호출하려고
class Notifier < ActionMailer::Base
def contact(recipient, subject, message, sent_at = Time.now)
@subject = subject
@recipients = recipient
@from = '[email protected]'
@sent_on = sent_at
@body["title"] = 'Signup Info'
@body["email"] = '[email protected]'
@body["message"] = message
@headers = {}
return true
end
end
컨트롤러/관리자
class AdministratorController < ApplicationController
def index
recipient = "[email protected]"
subject = "Subject"
message = "message"
Notifier.deliver_contact(recipient, subject, message)
end
end
:
,210도와주세요 ...
해당보기 디렉토리에 어떤 파일이 있습니까? – rkb
테스트를 위해 방금보기 폴더에 contact.html.erb 빈 파일을 만들었습니다. – ramesh