actionmailer

Send an email manually of a specific page in rails app

有些话、适合烂在心里 提交于 2019-12-12 09:26:52
问题 I have a basic application that gathers savings data for clients each quarter. There is a view that shows this data for each client compared to other client data with charts and graphs. I'm looking for an easy way to implement a button (or something) that allows me to manually send that view to the client in an html email at my discretion. I have only found tutorials showing how to send emails upon registration or confirmation type emails. 回答1: # app/mailers/user_mailer.rb class UserMailer <

Setting a default queue for ActionMailer deliver_later?

给你一囗甜甜゛ 提交于 2019-12-12 08:20:39
问题 You can specify which queue to use when calling deliver_later in an ActionMailer by adding :queue as optional argument, e.g.: Notifier.welcome(User.first.id).deliver_later(queue: "low") Is there a way to do this in a general way, for all ActionMailers? To set the default ActionMailer queue? 回答1: Before Rails 5 Looking through Rails' source code you can see that they already set the default queue name as ' mailers '. Still, if you want to change that default you can always override it by

How to Integrate 'premailer' with Rails

此生再无相见时 提交于 2019-12-12 07:14:39
问题 How does one integrate the 'premailer' gem with a Rails (3.0.7) project? I currently have in my mailer: def welcome(user) @user = user mail to: user.email, subject: "Welcome" end But I can't figure out how to integrate the library. I need to call: premailer = Premailer.new(html) html = premailer.to_inline_css However, I'm not sure how to access the contents of my email from a mailer action. 回答1: Try: def premailer(message) message.text_part.body = Premailer.new(message.text_part.body.to_s,

Rails Actionmailer to email specific group of users based on User attribute being included in array

这一生的挚爱 提交于 2019-12-12 04:44:51
问题 I have a Document model with a string column access and a User model with a string column team . In a Document I can enter an array of items for access such as "staff, sales, manager". Meanwhile, a User has only one item under team . I am trying to send emails to specific Users based on whether or not for each user.team is included in the array for Document.access . For example if Document.access = "sales, management" , only Users with team = "sales" or team = "management" will be sent the

ActionMailer doesn't work in production

落爺英雄遲暮 提交于 2019-12-12 03:32:31
问题 All of my app's functionality works except the email function. Everything works fine and as expected in development. I hosted the app using DigitalOcean's Ruby on Rails one-click server setup. Here is a link to the instructions: https://www.digitalocean.com/community/tutorials/how-to-use-the-ruby-on-rails-one-click-application-on-digitalocean Here is my development.rb Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the

How may i apply sleep functionality on array in Ruby on rails

微笑、不失礼 提交于 2019-12-12 03:27:44
问题 I am working on a project in rails where i have used pluck @employees = Employee.where.not("status = ? AND strftime('%d/%m', date_of_birth) = ?", "Active" , date.strftime('%d/%m')).pluck(:email) mail(to: @employees, subject: 'Birthday Invitation') when i am sending email using Whenever gems,email is not going.I am getting Rake aborted error so how may i send email to more emp. 回答1: Try below code mailer def birthday_email date = Date.today @employees = Employee.where("status = ? AND strftime(

Ruby on Rails: Send email from show page

对着背影说爱祢 提交于 2019-12-12 02:54:07
问题 I am a Rails noob and have a problem sending an email from a show page. There are several contact form tutorials out there but I cannot find one where I send an email from a page like a 'show' page. I have big errors in my routes I believe. In the model I state that Users have several Promotions and on the promotions show page I want to allow the current_user to send an email to @user. here is app/mailers/quote_mailer.rb class QuoteMailer < ActionMailer::Base default :from => "tim@example.com

emails: server sends but a user doesn't receive

痴心易碎 提交于 2019-12-12 02:47:32
问题 I'm facing a weird bug. Trying to set up welcome email after a user's registration. According to server logs, my code sends an email but a user doesn't receive it. Here is my code: models/user.rb after_create :welcome_message private def welcome_message UserMailer.welcome_email(self).deliver end and mailers/user_mailer.rb def welcome_email(user) @user = user mail to: @user.email, subject: t("mailer.welcome_email.welcome") end here are environments. The error occurs in both of them config

Sending object as a variable to Mandrill via Rails

删除回忆录丶 提交于 2019-12-12 02:27:49
问题 I'm converting an email template from Rails to Mandrill, the content for which requires a fair amount of data, some of which is nested through several associations. Therefore, I'd like to pass objects via Mandrill's global_merge_vars, such as the (simplified) following: [{ 'name'=>'order', 'content'=> @order.to_json(include: { user: { only: :first_name } }, methods: [:method1, :method2, :method3, :method4]) }] Which passes through to the mandrill template under the order variable similar to

Rails 3.0.7 ActionMailer attachment issue

穿精又带淫゛_ 提交于 2019-12-12 01:34:14
问题 I'm trying to attach a file to an outgoing email but the attachment size ends up being 1 byte. It doesn't matter what attachment I'm forwarding it always ends up in the email 1 byte in size (corrupt). Everything else looks ok to me. The email information is pulled from an IMAP account and stored in the database for browsing purposes. Attachments are stored on the file system and it's file name stored as an associated record for the Email. In the view there's an option to forward the email to