Questions tagged [actionmailer]

Action Mailer is a framework for designing email service layers. Original ActionMailer is written in Ruby, but there is also implementation for ASP.NET MVC.

Action Mailer is a framework for designing email service layers. These layers are used to consolidate code for sending out forgotten passwords, welcome wishes on signup, invoices for billing, and any other use case that requires a written notification to either a person or another system.

Action Mailer is in essence a wrapper around Action Controller and the Mail gem. It provides a way to make emails using templates in the same way that Action Controller renders views using templates.

Additionally, an Action Mailer class can be used to process incoming email, such as allowing a blog to accept new posts from an email (which could even have been sent from a phone).

2387 questions
29
votes
6 answers

Where do I put helper methods for ActionMailer views?

I have a method that takes an array of strings and joins them so they do something like this: >> my_arr => ["A", "B", "C"] >> and_join(my_arr) => "A, B, and C" Which I'd like my mailer to have access to so I can output some information into an…
aarona
  • 35,986
  • 41
  • 138
  • 186
29
votes
4 answers

New rails 4.1 mailer preview action not found error

Rails has 607 open issues...so, rather than plugging that hole even more I though Id try here first. I have upgraded to 4.1 and am implementing rails mailer previews. I tried upgrading my existing mailer and adding tests/mailers/previews…
hellion
  • 4,602
  • 6
  • 38
  • 77
29
votes
9 answers

Problem sending multipart mail using ActionMailer

I'm using the following code to send emails in rails: class InvoiceMailer < ActionMailer::Base def invoice(invoice) from CONFIG[:email] recipients invoice.email subject "Bevestiging Inschrijving…
Pieter Jongsma
  • 3,365
  • 3
  • 27
  • 30
28
votes
2 answers

ActionMailer 3 without Rails

I'm writing a small Ruby program that will pull records from a database and send an HTML email daily. I'm attempting to use ActionMailer 3.0.3 for this, but I'm running in to issues. All the searching I've done so far on using ActionMailer outside…
Spencer R
  • 1,118
  • 2
  • 14
  • 34
28
votes
2 answers

ActionView::Template::Error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true

My ruby on rails action mailer runs all good in development environment, but in production environment, it keeps throw: ActionView::Template::Error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set…
Chuanpin Zhu
  • 2,226
  • 1
  • 21
  • 21
27
votes
3 answers

ActionMailer and development mode, can it write to a file or something?

I want to test my registration process locally (development mode), how can I test how emails will be sent out and rendered etc? I am not referring to a unit-test or integration test, but just while developing my app and going on the register page…
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
27
votes
4 answers

Rails for ActionMailer - How to disable a Layout for a certain mailer

I have a user_mailer with a layout. For one of my actionmailer methods I want the mailer to NOT use the default layout. But I can't see to find a setting for No Layout. Any ideas?
AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012
27
votes
4 answers

Execute pending job with ActiveJob in rspec

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 …
Olivier
  • 493
  • 2
  • 6
  • 16
27
votes
3 answers

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

I want to have emails I send out with ActionMailer contain images that link back to my app. In my development environment, for example: I have this in my…
26
votes
5 answers

How to catch error exception in ActionMailer

The problem is how can I catch exception in delivering mail by ActionMailer. For me it sounds impossible, because in this case ActionMailer should sent mail to mailserver, and if mailserver returns error, ActionMailer should show me this error. I am…
com
  • 2,606
  • 6
  • 29
  • 44
26
votes
3 answers

How do I create email with css and images from Rails?

How do you create and send emails from Rails application, that contain images and proper formatting? like the ones you get from facebook and like.
Akshay
  • 11,803
  • 5
  • 29
  • 26
26
votes
7 answers

How can I send emails in Rails 3 using the recipient's locale?

How can I send mails in a mailer using the recipient's locale. I have the preferred locale for each user in the database. Notice this is different from the current locale (I18n.locale), as long as the current user doesn't have to be the recipient.…
Jose
  • 609
  • 1
  • 7
  • 15
26
votes
1 answer

Setting a default queue for ActionMailer deliver_later?

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…
Hallgeir Wilhelmsen
  • 1,014
  • 1
  • 10
  • 18
26
votes
3 answers

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

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 …
bulleric
  • 2,077
  • 6
  • 21
  • 36
25
votes
3 answers

Prevent Rails from logging email attachments

When I send an email with an attachment the data is logged in hex and fills up my whole log. Is there a way to disable logging of attachments? I know I can disable mailer logging with config.action_mailer.logger = nil.
m33lky
  • 7,055
  • 9
  • 41
  • 48