2012-07-18 66 views
0

我已将一个联系表单添加到我的网站,并且遇到问题,当邮件发送时,我收到我的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 

上午我错过了任何明显的在这里,因为我已经在另一个网站工作得很好,只是不知道发生了什么

任何帮助表示赞赏

+0

你分析的日志?搜索“发送邮件到[RECEIVER'S EMAIL]”以检查邮件是否已成功发送。如果你找到类似的日志,那么检查你的垃圾邮件文件夹是否包含邮件 – 2012-07-20 12:47:00

+0

我知道这是一个老问题,你可能已经开始了,但我首先要验证你是否可以使用控制台成功发送电子邮件。在那里实例化并发送电子邮件。 – Tass 2015-03-24 14:46:50

回答

1

我知道你把它在你的应用程序/ config.rb,但我会保证config.action_mailer.perform_deliveries没有被覆盖在你的config /环境/ development.rb

+0

感谢您的回答,theres没有在我的配置/环境/开发将重写,仍然无法正常工作 – Richlewis 2012-07-18 20:18:56