Tag: actionmailer

邮件程序错误丢失模板

你好, 当我尝试执行操作时,我遇到了ActionMailer的问题: rake send_email 我收到一个错误: rake aborted! ActionView::MissingTemplate: Missing template user_mailer/mailer with “mailer”. Searched in: * “user_mailer” 这是我的: 邮寄/ user_mailer.rb class UserMailer < ActionMailer::Base default from: "from@example.com" def mailer(user) @user = user mail(to: @user.email, subject: 'Test') end end 视图/ user_mailer文件/ mailer.html.erb Sample mail. 视图/ user_mailer文件/ mailer.text.erb Sample mail. LIB /任务/ emails_task.rake desc ‘send email’ task […]

ActionMailer将局部变量传递给erb模板

我知道我可以定义实例变量,例如: def user_register(username, email) @username = username @email = email mail(:to => email, :subject => “Welcome!”, :template_name => “reg_#{I18n.locale}”) end 但是,是否有一种方法可以使用局部变量,就像传递:locals到partials一样?

Sidekiq和rails 4 actionmailer永远不会发送电子邮件

我在rails 4应用程序中设置了sidekiq,用于发送电子邮件和处理后台作业。 我还设计了我使用devise_async和典型的联系表单电子邮件。 我正在使用Gmail发送电子邮件。 如果我删除sidekiq,它通常通过gmail(设计和联系表单)发送电子邮件,但是当我启用它时,它不起作用(devise_async都不是联系表单)。 Sidekiq显示后台作业开始并成功完成(我也通过sinatra应用程序看到它们已被处理)但电子邮件从未发送过。 在开发过程中,控制台显示发送的电子邮件(使用devise_async和联系表单,因为它们已成功处理sidekiq)。 我已经尝试过的: 我为sidekiq的rails4添加了github分支(我也尝过了主人) 我已经更新并检查redis版本是否大于2.4(它是2.6.14) 我正在使用bundle exec sidekiq运行bundle exec sidekiq 但没有任何效果。 我使用的是ruby 2.0.0-p247。 我还在这个应用程序中使用sidekiq设置图像处理,在开发和生产中都能很好地工作。 我没有做任何花哨的事情,但我正在添加完成代码: 我的邮件代码: def send_message @message = Message.new(message_params) if @message.save ContactMailer.delay.contact_form(@message.id) end end 我的邮件: def contact_form(message_id) message = Message.where(id: message_id).first @email = message.email @message = message.text mail(to: “myemail@gmail.com”, subject: “Message from contact form”) end 和我的生产配置(没有sidekiq它的工作原理): config.action_mailer.delivery_method = […]

Rails 4.2 – Sidekiq不在开发中发送电子邮件

我有一个rails应用程序,我有一个方法,我发送了很多电子邮件。 我想asynchronously执行此操作。 要做到这一点,我试图使用Sidekiq ,但我不能让它正常工作 – 它不发送任何电子邮件。 以前发送电子邮件,所以我确定我的电子邮件设置已正确设置。 在我的gemfile我有这个: gem ‘sidekiq’ 我已经运行了bundle install 。 我还安装了redis ,遵循RailsCasts#366上的说明。 我已经使用以下命令启动了sidekiq : bundle exec sidekiq ,这导致了下图中可以看到的内容: 在application.rb我有以下内容: config.active_job.queue_adapter = :sidekiq 我尝试发送这样的电子邮件: Mailer.deliver_new_competition_notification(member.user, @competition).deliver_later! 我没有收到任何错误,但电子邮件永远不会被发送。 那么,我错过了什么吗?

为什么Rails实例方法可以用作rspec中的类方法

我在一篇关于在Rails应用程序中发送邮件的文章中找到了一个片段: class ExampleMailerPreview < ActionMailer::Preview def sample_mail_preview ExampleMailer.sample_email(User.first) end end 在此链接: http : //www.gotealeaf.com/blog/handling-emails-in-rails 。 我不知道为什么方法: sample_email() ,在我看来应该是一个实例方法,可以像ExampleMailer.sample_email()一样在类方法中访问。 谁有人解释一下?

单引号字符串字符串插值

我正在尝试使用Rails在ActionMailer中设置电子邮件地址。 在硬编码之前,我们现在想让它们成为ENV变量,这样我们就不需要在每次电子邮件更改时修改代码。 以下是它目前的定义: from = ‘”Name of Person” ‘ 我已尝试使用ENV[‘EMAIL’]将电子邮件设置为环境变量,但即使使用#{ENV[‘EMAIL’}我也没有运气。 谁能指出我正确的方向?

动作邮件SMTP谷歌应用程序

我尝试配置actionmailer以通过谷歌应用程序与smtp发送。 config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { :address => “smtp.gmail.com”, :port => 587, :domain => “mydomain.com”, :user_name => “username”, :password => “password”, :authentication => ‘plain’, :enable_starttls_auto => true } config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = true 但是每当gitlab尝试发送电子邮件时: Sent mail to user@my.domain.com (10ms) Completed 500 Internal Server Error in 29ms 535-5.7.1 Username and Password not accepted 服务器运行ruby […]

如何将’premailer’与Rails集成

如何将’ premailer’gem与Rails(3.0.7)项目集成? 我目前在我的邮件中: def welcome(user) @user = user mail to: user.email, subject: “Welcome” end 但我无法弄清楚如何整合图书馆。 我需要打电话: premailer = Premailer.new(html) html = premailer.to_inline_css 但是,我不确定如何从邮件程序操作访问我的电子邮件的内容。

rails email error – 530-5.5.1需要validation。

尝试从Ruby on Rails发送电子邮件,但得到这个: SocketError in UsersController#create getaddrinfo: nodename nor servname provided, or not known 我的environment / development.rb文件有: config.action_mailer.smtp_settings = { address: “smtp.gmail.com”, port: 587, domain: “my_company.org”, authentication: “plain”, enable_starttls_auto: true, user_name: “my_username@my_company.org”, password: “my_pass” } 和 config.action_mailer.delivery_method = :smtp 和 config.action_mailer.default_url_options = { :host => ‘localhost:5000’ } # 5000 rather than 3000 as I am […]

“actionmailer”的未定义方法“name”:String

我有一个旧版本的Rails项目,它是在config / environment文件中使用BrowserCMS构建的 RAILS_GEM_VERSION = ‘2.3.4’ unless defined? RAILS_GEM_VERSION 所以我使用rvm安装了这个gem,所以我可以运行它 $ gem list *** LOCAL GEMS *** actionmailer (2.3.8, 2.3.4) actionpack (2.3.8, 2.3.4) activerecord (2.3.8, 2.3.4) activeresource (2.3.8, 2.3.4) activesupport (2.3.8, 2.3.4) bundler (1.1.4) mysql (2.8.1) rack (1.1.3, 1.0.1) rails (2.3.4) rake (0.8.7) 我运行rake db:create它工作正常,但是当我运行rake db:migrate了这个错误 rake aborted! undefined method `name’ for “actionmailer”:String 我尝试过使用Trace,但我没有得到任何帮助 $ […]