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
43
votes
1 answer

The method `add_template_helper` does not seem to work in Rails 6.1

After updating my project to Rails 6.1 I get this error: NoMethodError: undefined method `add_template_helper' for ApplicationMailer:Class In the documentation does not seem to be deprecated.
Daniel
  • 4,051
  • 2
  • 28
  • 46
42
votes
1 answer

ActionMailer testing with rspec

I am developing a Rails 4 application which involves sending / receiving emails. For example, I send emails during user registration, user comment, and other events in the app. I have created all emails using the action mailer, and I used rspec and…
Dinkaran Ilango
  • 513
  • 1
  • 4
  • 11
40
votes
3 answers

Setting up a Gmail Account to work with ActionMailer in Rails 3

I have a contact page form that is setup to send an email to a Gmail account. Only problem is it won't send. I believe I have narrowed the error down to my settings inside of the initializers directory. These are my current settings for trying to…
ab217
  • 16,900
  • 25
  • 74
  • 92
39
votes
4 answers

Render Different View (template) for ActionMailer

I'm trying to do a conditional render of a different template from ActionMailer (Rails 3.1.1). I want most users to get the normal welcome.html.erb template, but some users to get the special welcome_photographer.html.erb template. This type of…
brittohalloran
  • 3,534
  • 4
  • 28
  • 27
39
votes
8 answers

Rails Mailer "Net::OpenTimeout: execution expired" Exception on production server only

I am using Ruby MRI 2.0.0 and Rails 3.2.12 on a Ubuntu 12.04 TLS VPS and attempting to setup email notifications in my app. It was working fine a few days ago, but not anymore. My web host is OVH. My SMTP…
38
votes
11 answers

Rails ActionMailer with multiple SMTP servers

I have a need to use two different smtp servers in a Rails application. It appears that the way ActionMailer is constructed, it is not possible to have different smtp_settings for a subclass. I could reload the smtp settings for each mailer class…
user189053
37
votes
1 answer

How do I create a Mailer Observer

I'd like to run some code whenever an email is sent on my app. As ActionMailer doesn't support after_filter, I would like to use an observer. The Rails docs mention this in passing, however does not elaborate. Thanks!
thomasfedb
  • 5,990
  • 2
  • 37
  • 65
34
votes
2 answers

Rails - How to test that ActionMailer sent a specific attachment?

In my ActionMailer::TestCase test, I'm expecting: @expected.to = BuyadsproMailer.group_to(campaign.agency.users) @expected.subject = "You submitted #{offer_log.total} worth of offers for #{offer_log.campaign.name} " @expected.from = "BuyAds…
33
votes
5 answers

Testing ActionMailer multipart emails(text and html version) with RSpec

I'm currently testing my mailers with RSpec, but I've started setting up multipart emails as described in the Rails Guides here: http://guides.rubyonrails.org/action_mailer_basics.html#sending-multipart-emails I have both mailer templates in text…
cmhobbs
  • 2,469
  • 3
  • 24
  • 30
32
votes
5 answers

Ruby mailer is coming up with an EOFError

I am getting an EOFError (End Of File Error) on this code in my controller. The block where the error appears is at the end of the line that says UserMailer.deliver_message( I am unaware as to how to fix this, I have been stuck for about 2 months…
Deadder
  • 535
  • 1
  • 4
  • 16
31
votes
2 answers

How to disable ActionMailer in Development?

sometimes when I am developing, I do not have an internet connection. This results in an error wherever my app is supposed to send an email: getaddrinfo: nodename nor servname provided, or not known Is there a simple and quick way where i can…
30
votes
1 answer

how to define a host with https in action_mailer.default_url_options

ActionMailer provides a way to define the host to use with resource helpers: config.action_mailer.default_url_options = { :host => "example.com" } I can't find a way to force this to https.
m33lky
  • 7,055
  • 9
  • 41
  • 48
30
votes
5 answers

How To Send E-Mails With BCC in Rails 3

How can I send e-mails with the BCC header? I follow the ruby on rails guide and set :bcc => "email@email.com" and it doesn't work. Thanks edit by corroded Here's the code I tried: def booking_confirmed_email(booking) @booking = booking mail(:to…
silkwormy
  • 667
  • 2
  • 10
  • 17
30
votes
5 answers

Rails Action Mailer: images in emails

I'm trying to paste images into email. The problem is emails comming without images inside development.rb config.action_mailer.default_url_options = { :host => 'localhost:3000', :only_path => false } …
Pavel
  • 1,934
  • 3
  • 30
  • 49
29
votes
4 answers

gmail smtp with rails 3

I am trying to get a confirmation email sending using a gmail account. I have looked around and there is nothing that is obvious. There is no errors or anything, it just dosn't send I have this as the initalizer: ActionMailer::Base.delivery_method =…
elasticmonkey
  • 307
  • 1
  • 3
  • 3