0
我有一個聯繫表格設置,我使用的是Gmail。但是我沒有收到任何郵件。我收到了發送消息的閃爍警報,但是在日誌中查看它沒有顯示該電子郵件正在創建。不接收來自聯繫表格的郵件
有人可以看看並幫助我嗎?
contact_mailer.rb:
default :from => "[email protected]"
def new_contact(contat)
@contact = message
end
end
development.rb:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'gmail.com',
user_name: '[email protected]',
password: 'password',
authentication: 'plain',
enable_starttls_auto: true }
config.action_mailer.default_url_options = { :host => "localhost:3000" }
end
聯繫控制器:
def create
@contact = Contact.new(params[:message])
if @contact.valid?
ContactMailer.new_contact(@contact).deliver
flash[:notice] = "Message sent! Thank you for contacting us."
redirect_to root_url
else
render :action => 'new'
end
聯繫型號:
def initialize(attributes={})
attributes && attributes.each do |name, value|
send("#{name}=", value) if respond_to? name.to_sym
end
end
登錄:
Started POST "/contacts" for 127.0.0.1 at 2014-04-16 15:59:35 -0400
Processing by ContactsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"WN19FGciesn2QUiaMtxv4Lwo48tRTkFBSud7OPGRTts=", "contact"=>{"email"=>"[email protected]", "content"=>"This is a bot."}, "commit"=>"Send Message"}
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`auth_token` = 'Mqy5_1kyb4hAsrmB9Q0fug' LIMIT 1
Redirected to http://localhost:3000/
Completed 302 Found in 6ms (ActiveRecord: 0.4ms)
Started GET "/" for 127.0.0.1 at 2014-04-16 15:59:35 -0400
Processing by UsersController#index as HTML
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`auth_token` = 'Mqy5_1kyb4hAsrmB9Q0fug' LIMIT 1
Rendered searches/_new.html.erb (5.5ms)
User Load (0.3ms) SELECT `users`.* FROM `users`
Rendered users/index.html.erb within layouts/application (8.6ms)
(0.7ms) SELECT COUNT(*) FROM `conversations` INNER JOIN `notifications` ON `notifications`.`conversation_id` = `conversations`.`id` AND `notifications`.`type` IN ('Message') INNER JOIN `receipts` ON `receipts`.`notification_id` = `notifications`.`id` WHERE `notifications`.`type` = 'Message' AND `receipts`.`mailbox_type` = 'inbox' AND `receipts`.`trashed` = 0 AND `receipts`.`deleted` = 0 AND `receipts`.`receiver_id` = 2 AND `receipts`.`receiver_type` = 'User' AND `receipts`.`is_read` = 0
Completed 200 OK in 81ms (Views: 78.5ms | ActiveRecord: 1.4ms)
我加了你什麼建議和郵件沒有被交付依然。我重新啓動服務器也要注意。 – xps15z
@ xps15z:更新了答案。 – zrl3dx
謝謝。我需要'mail'方法併爲它添加一個視圖。現在我只需修復'535-5.7.8用戶名和密碼不被接受'的錯誤。謝謝! – xps15z