首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Actionmailer Rails 3

Actionmailer Rails 3
EN

Stack Overflow用户
提问于 2012-07-19 03:54:15
回答 1查看 564关注 0票数 0

我已经添加了一个联系形式到我的网站,并有一个问题,当消息发送时,我收到我的闪光消息,“成功发送”,但电子邮件从未到达我的收件箱。我现在处于开发模式,我的app/config文件如下所示

代码语言:javascript
复制
   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"
      }

我的联系人控制器是这样的

代码语言:javascript
复制
      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

最后是我的通知邮件程序

代码语言:javascript
复制
      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

我是不是遗漏了什么明显的东西,因为我在另一个网站上实现了这个功能,这个网站工作得很好,只是弄不清楚发生了什么。

感谢您的任何帮助

EN

回答 1

Stack Overflow用户

发布于 2012-07-19 04:01:07

我知道您在您的应用程序/config.rb中设置了它,但我要确保config.action_mailer.perform_deliveries不会在您的配置/environments/development.rb中被覆盖

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11549223

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档