我已將一個聯繫表單添加到我的網站,並且遇到問題,當郵件發送時,我收到我的Flash消息「已成功發送」,但該電子郵件從未到達我的收件箱。我在開發模式在此刻和我的應用程序/ config文件看起來像這樣Actionmailer Rails 3
class Application < Rails::Application
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "[email protected]",
:password => "example",
:authentication => :plain,
:enable_starttls_auto => true
}
config.action_mailer.default_url_options = {
:host => "gmail.com"
}
我接觸控制器是這樣
def new
@message = Message.new
end
def create
@message = Message.new(params[:message])
if @message.valid?
NotificationsMailer.new_message(@message).deliver
redirect_to(root_path, :notice => "Message was successfully sent.")
else
flash.now.alert = "Please fill all fields."
render :new
end
end
end
,最後我的郵件通知器
class NotificationsMailer < ActionMailer::Base
default :from => "[email protected]"
default :to => "[email protected]"
def new_message(message)
@message = message
if message.file
attachment_name = message.file.original_filename
attachments[attachment_name] = message.file.read
end
mail(:subject => "[[email protected]] #{message.subject}")
end
end
上午我錯過了任何明顯的在這裏,因爲我已經在另一個網站工作得很好,只是不知道發生了什麼
任何幫助表示讚賞
你分析的日誌?搜索「發送郵件到[RECEIVER'S EMAIL]」以檢查郵件是否已成功發送。如果你找到類似的日誌,那麼檢查你的垃圾郵件文件夾是否包含郵件 – 2012-07-20 12:47:00
我知道這是一個老問題,你可能已經開始了,但我首先要驗證你是否可以使用控制檯成功發送電子郵件。在那裏實例化併發送電子郵件。 – Tass 2015-03-24 14:46:50