actionmailer

Principles on how to send a mass mailer without it ending up in junk mail

◇◆丶佛笑我妖孽 提交于 2019-12-04 05:01:05
I put together a really nice mass mailer, but occasionally mails end up in junkmail on various different mail providers for various reasons. Does anyone know if there is a write up anywhere on best practices to send mass mailers? MailChimp have a good document which covers key points (IP ranges, rate limiting, SPF/DKIM, bounce handling, feedback loops). As an aside, it's unusual to see something so comprehensive from a company whose business is based around doing this kind of stuff for other people - presumably they hope it'll make you think twice before building something from scratch! 来源:

Execute pending job with ActiveJob in rspec

江枫思渺然 提交于 2019-12-04 00:32:44
I have this code to test ActiveJob and ActionMailer with Rspec I don't know how really execute all enqueued job describe 'whatever' do include ActiveJob::TestHelper after do clear_enqueued_jobs end it 'should email' do expect(enqueued_jobs.size).to eq(1) end end timsly Here is how I solved a similar problem: # rails_helper.rb RSpec.configure do |config| config.before :example, perform_enqueued: true do @old_perform_enqueued_jobs = ActiveJob::Base.queue_adapter.perform_enqueued_jobs @old_perform_enqueued_at_jobs = ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs ActiveJob::Base.queue

Setting a default queue for ActionMailer deliver_later?

孤者浪人 提交于 2019-12-04 00:07:06
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? mrstif 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 including the following code in an initialiser or loaded lib file: class ActionMailer::DeliveryJob queue

Actionmailer not delivering mail, with rails 3

十年热恋 提交于 2019-12-03 23:25:50
I am trying to make an application, that sends an email when user registers. i put in the smtp settings for gmail in the config/application.rb file and the mail function looks like mail(:to => "me@me.com", :subject => "Mail!", :from => "another@me.com", :content_type => "text/html") now when i see the logs, i see that it says mail has been sent, but i never receive any mail at all... also, when i call the mail deliver function, Emails.signed(@user).deliver , the form page does not redirect, but it works if i comment out the email sending code that is either Emails.signed(@user).deliver or mail

ActionMailer pass local variables to the erb template

℡╲_俬逩灬. 提交于 2019-12-03 15:57:50
问题 I know I could define instance variables e.g: def user_register(username, email) @username = username @email = email mail(:to => email, :subject => "Welcome!", :template_name => "reg_#{I18n.locale}") end But, is there a way to use local variables instead, just like passing :locals to partials? 回答1: All options available in the mail method can be found at http://api.rubyonrails.org/classes/ActionMailer/Base.html#method-i-mail. We know that render has a :locals option. However we can see that

Make a custom helper available to both Mailer and View in Rails 3.1

烂漫一生 提交于 2019-12-03 15:43:38
问题 is this the best way to make a helper available to both Mailer and view in Rails 3.1? class EventMailer < ActionMailer::Base include MailerHelper helper :mailer I tried helper :mailer on its own, but that didn't allow me to use the helpers in the EventMailer class. I tried add_template_helper(MailerHelper) but had the same problem. 回答1: The rails helpers are supposed to be view helpers. You will notice that the following code : class MyController < ApplicationController helper :my end will

ActionMailer password security

别说谁变了你拦得住时间么 提交于 2019-12-03 12:16:24
Am I crazy, or is it a bad idea to keep my SMTP username and password for ActionMailer in the actual (development/production) config file? It seems like I should store it an encrypted place, or at the very minimum, exclude it from my Mercurial pushes. Right now, I'm just removing the password from my source file before performing a push, but there's got to be a smarter way than the one I'm using. :) Perhaps I should store it in my database as another user (which is already stored with encrypted passwords) and fetch it programatically? Jimmy Cuadra Use an application configuration file that is

How to make Delayed_Job notify Airbrake when an ActionMailer runs into an error?

跟風遠走 提交于 2019-12-03 11:09:26
The DelayedJob docs mention hooks, including an error hook, but only in the context of custom Job subclasses. This similar question (with no answers) says adding the same hook to the mailer class did not work. What's the trick? Update: In general, I'd like to see how to add hooks to jobs that are triggered using the object.delay.action() syntax, where I don't see an obvious link to a ____Job class. I was just searching for a solution to this problem too, and I found this gist . I don't know where it comes from (found it on Google), but well, it seems to do the job pretty well, is quite simple,

How do I get full URL to an image in a Rails asynchronous mailer?

一笑奈何 提交于 2019-12-03 10:52:41
问题 I want to have emails I send out with ActionMailer contain images that link back to my app. In my development environment, for example: <img src="http://myfullappurl.dev/assets/myimage.png"> I have this in my development.rb config.action_controller.asset_host = 'myfullappurl.dev' config.action_mailer.asset_host = config.action_controller.asset_host config.action_mailer.default_url_options = { host: 'myfullappurl.dev', only_path: false } But I can not get my mail templates to render a full URL

ArgumentError: An SMTP To address is required to send a message. Set the message smtp_envelope_to, to , cc, or bcc address

泪湿孤枕 提交于 2019-12-03 09:37:12
I got an rails 4 application with following mailer configuration: config.action_mailer.delivery_method = :smtp config.action_mailer.default_url_options = { host: 'myhost.com' } config.action_mailer.perform_deliveries = true config.action_mailer.smtp_settings = { :enable_starttls_auto => true, :address => 'smtp.myhost.com', :port => 587, :domain => 'myhost.com', :authentication => :login, :enable_starttls_auto => false, :tls => false, :openssl_verify_mode => 'none', :ssl => false, :user_name => "myusername", :password => "mypassword" } Every time i try to send an mail with an testing mailer