0

我在我的网站上添加了一个联系表格,但遇到了一个问题,当我发送消息时,我收到了我的 Flash 消息,“成功发送”,但是电子邮件从未到达我的收件箱。我目前处于开发模式,我的应用程序/配置文件看起来像这样

   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  => "myemail@gmail.com",
    :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 => "myemail@gmail.com"
      default :to => "myemail@gmail.com"

     def new_message(message)
     @message = message
     if message.file
      attachment_name = message.file.original_filename
      attachments[attachment_name] = message.file.read
     end
     mail(:subject => "[myemail@gmail.com] #{message.subject}")
    end
     end

我是否在这里遗漏了任何明显的东西,因为我已经在另一个运行良好的站点中实现了这个,只是无法弄清楚发生了什么

任何帮助表示赞赏

4

1 回答 1

1

I know you set it in your app/config.rb, but I would ensure config.action_mailer.perform_deliveries isn't being overridden in your config/environments/development.rb

于 2012-07-18T20:01:06.753 回答