actionmailer

Setting instance variables in Action Mailer?

╄→гoц情女王★ 提交于 2019-12-07 06:27:19
问题 I am wondering what is a clean and conventional way for setting instance variables in Mailers? Currently, I have re-defined the initialize method in Mailer and subsequently overwrite certain instance variables when needed in any mailers that inherit from Mailer . class Mailer < ActionMailer::Base attr_reader :ivar def initialize super @ivar = :blah ... end end This only seems weird to me because new is a private method for mailers. For example, if I were to try to retrieve these in the rails

Rails: change default sender in action mailer

醉酒当歌 提交于 2019-12-07 05:46:07
问题 I am sending email using action mailer in my rails app. But it allows only one default sender. This is my UserMailer class: class UserMailer < ActionMailer::Base default :from => "example@example.com" def welcome_email(user, order) @user = user @order = order mail(:to => user.email, :subject => "Your Order") end def signup_email(user) @user = user mail(:to => user.email, :subject => "Thank you.") end def invite_confirm(curuser,usemail,post) @greeting = "Hi" @user = curuser @post = post mail(

Using ActionMailer with a company Gmail account

ぃ、小莉子 提交于 2019-12-07 05:34:27
问题 I'm not sure if this belongs in server fault or here feel free to move it if it makes more sense somewhere else. I've seen the examples for setting up the smtp settings and using ActionMailer with Gmail and confirmed that they work for me. Basically it looks like this for me: config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { :address => "smtp.gmail.com", :port => 587, :user_name => '<username>', :password => '<password>', :authentication => 'plain', :enable

Action::Mailer not delivering mail to the recepients

自古美人都是妖i 提交于 2019-12-07 05:19:41
问题 I tried to send mail to the user when his profile is being viewed. i.e When a user clicks on show of a particular contact that contact will be notified about the profile view. I did not get any errors. But there is some delay where i have triggered the mailer. And also it works fine in the console. But the mail is not being sent to the recepient. This is what I have tried so far. mailer.rb : class CustomerSupport < ActionMailer::Base def customer_support(contact) mail :to => contact.email,

Rails Send 2 different emails from one mailer function

白昼怎懂夜的黑 提交于 2019-12-07 03:58:19
问题 I have a need to do so, because it seems logical to me: def notification(vehicle) @vehicle = vehicle mail(:to => @vehicle.owner.email_address, :template_name => "n_o") mail(:to => @vehicle.booker.email_address, :template_name => "n_b") end The problem is: I'm receiving only the last e-mail. So, in my example above, only the booker would receive the email and nothing is being sent to the owner. What is the problem ? How to solve it ? Should I create two separate mailing functions, like

Redirect all outgoing emails to single address for testing

北城以北 提交于 2019-12-07 03:46:11
问题 In Ruby on Rails, I'm in a situation where I'd like my application (in a particular testing environment) to intercept all outgoing emails generated by the application and instead send them to a different, testing address (maybe also modifying the body to say "Initially sent to: ..."). I see ActionMailer has some hooks to observe or intercept mail, but I don't want to spin my own solution if there's an easier way to do this. Suggestions? 回答1: We're using the sanitize_email gem with much

Rails ActionMailer ignores settings in environment.rb

不打扰是莪最后的温柔 提交于 2019-12-07 02:28:52
问题 I put my ActionMailer config in my config/environment.rb file like so: MyApp::Application.initialize! MyApp::Application.configure do config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { address: "smtp.elasticemail.com", port: 2525, domain: "myapp.com", authentication: "plain", user_name: "my_username", password: "my_password", enable_starttls_auto: true } end My understanding is that this is the correct way to configure settings that will apply to all your

In Rails 3 and ActionMailer, is it possible to send email using TLS over SSL (Not StartTLS)?

安稳与你 提交于 2019-12-07 01:46:58
问题 I would like to use ActionMailer to send emails from my rail app. I have an existing mail server that I would like to use, however it only supports SSL/TLS on port 465. It does not, however, support StartTLS (typically on port 587). Can anyone suggest a way of achieving this? As far as I can tell there is no support out of the box for this. I am using Rails 3.0.7. 回答1: Yes, you can specify the :ssl option. Set the following values in your config/environments/production.rb file: config.action

Rails before_action for ActionMailer that would use mailer arguments

谁说胖子不能爱 提交于 2019-12-06 23:13:15
问题 Suppose I have a mailer that sends different emails, but is expected to be called with the same parameters. I want to process those parameters for all mailer actions. So, calling a before_action that would read the parameters sent to the mailer method /mailers/my_mailer.rb class MyMailer < ApplicationMailer before_filter do |c| # c.prepare_mail # Will fail, because I need to pass `same_param` arguments # # I want to send the original arguments # c.prepare_mail(same_param) # How do I get `same

Send an email through gmail but configure a different email address

雨燕双飞 提交于 2019-12-06 16:45:51
I'm trying to send emails from my rails application using GMail's smtp server. The emails I send appear like sent from my own gmail address, while I would like them to be coming from info@myapp.com. I've configured the thing using the three ways authentication, and my app has got its unique password. Here's my production.rb config.action_mailer.default_url_options = { host: 'my ip', protocol: 'https' } config.action_mailer.delivery_method = :smtp config.action_mailer.asset_host = "https://my ip" and here's my initializers/smtp.rb MyApp::Application.configure do config.action_mailer.smtp