actionmailer

Setting instance variables in Action Mailer?

ぐ巨炮叔叔 提交于 2019-12-05 10:45:47
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 console, I need to do the following: mailer = Mailer.send(:new) mailer.ivar I have also considered

Mailer error missing template

眉间皱痕 提交于 2019-12-05 10:06:54
问题 Hello, I have problem with ActionMailer , when I try to execute action: rake send_email I get a error: rake aborted! ActionView::MissingTemplate: Missing template user_mailer/mailer with "mailer". Searched in: * "user_mailer" Here's my: mailers/user_mailer.rb class UserMailer < ActionMailer::Base default from: "from@example.com" def mailer(user) @user = user mail(to: @user.email, subject: 'Test') end end views/user_mailer/mailer.html.erb <!DOCTYPE html> <html> <head> <meta content='text/html;

Using ActionMailer with a company Gmail account

寵の児 提交于 2019-12-05 09:52:44
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_starttls_auto => true } What I need to do now is to send an email to an address that isn't a plain Gmail

actionmailer encoding - rendering garbage in email client

匆匆过客 提交于 2019-12-05 09:27:12
I have both text and html parts for my emails. Users are reporting 'garbage characters' in some cases where the email is include values from the db. It seems to be an issue when unicode characters are involved. I created trivial template that just echos back the value for both the text and html parts ( <%= @body_text %> ) and tested it out with a sample string: a permanent feature ë When I see this string in gmail it looks like: a permanent feature ������ Inspecting the header I see this on the mail: Content-Type: multipart/alternative; charset=UTF-8 Content-Transfer-Encoding: 7bit and then

Rails Send 2 different emails from one mailer function

余生颓废 提交于 2019-12-05 06:33:30
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 notification_owner(vehicle) and notification_booker(vehicle), or there is a simplier solution ? Thanks! Ok. So

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

浪尽此生 提交于 2019-12-05 06:30:17
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. Matt Connolly Yes, you can specify the :ssl option. Set the following values in your config/environments/production.rb file: config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { address: 'mail.example

Rails - Use same attachment for all emails using layout

徘徊边缘 提交于 2019-12-05 05:19:06
I'm probably missing something obvious, but I've got a logo I'd like to include in all of the emails I send from my app. I have a master layout I'm using for all of those Mailers. I assume there's a way to do keep it DRY and not have to add the line of code to attach the file in every mailer method. Can someone point me in the right direction or correct my line of thought. Thanks! Callbacks using before_filter and after_filter will be supported in a future Rails release: http://github.com/rails/rails/commit/4f28c4fc9a51bbab76d5dcde033c47aa6711339b Since they will be implemented using

How to change the mailer Content-Transfer-Encoding settings in Rails?

此生再无相见时 提交于 2019-12-05 04:21:38
The 'Content-Transfer-Encoding' setting is set to '7bit' by default. The mail server Postfix is breaking down the email header by bunch of 1000 caracteres, meaning that if you have a long email (using HTML for example), you end up having spaces in the middle of your text or links. (See this thread for more info: http://tech.groups.yahoo.com/group/postfix-users/message/273296 ) Following the Rails ActionMailer documentation (http://api.rubyonrails.org/classes/ActionMailer/Base.html), adding the following code to my app file should make it, but it doesn't work: ActionMailer::Base.default

Rails before_action for ActionMailer that would use mailer arguments

依然范特西╮ 提交于 2019-12-05 03:01:01
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_param` here ? end def action1(same_param) # email view is going to use @to, @from, @context method

Ruby on Rails-Action mailer no as per desired?

此生再无相见时 提交于 2019-12-04 20:36:18
i have 2 models po and send po: has_many sends send: belongs_to po send po send_controller class SendsController < ApplicationController def new @send = Send.new end def create @send = Send.new(params[:send]) if @send.save Pomailer.registration_confirmation(@send).deliver flash[:success] = "Send mail" redirect_to capax_path else flash[:warning] = "mail not send" redirect_to capax_path end end pomailer class Pomailer < ActionMailer::Base default from: "from@example.com" def registration_confirmation(po) @po = po mail(:to => "xyz@yahoo.co.in", :subject => " New purchase order send by " ) end end