actionmailer

Send an actionmailer email upon user registration in devise rails 3 application

China☆狼群 提交于 2019-12-08 12:30:23
问题 I'm trying to send an email upon user registration in a rails 3 application that is using the devise gem. Every time I try to the send the email I get the following error: NoMethodError in Devise::RegistrationsController#create undefined method `welcome_email' for UserMailer:Class My app/model/user.rb has the following code... after_create :send_welcome_email def send_welcome_email UserMailer.welcome_email(self).deliver end My app/mailers/user_mailer.rb has the following code... class

ActionMailer and Exchange

混江龙づ霸主 提交于 2019-12-08 06:40:28
问题 I successfully send Mails via SMTP using my Rails App and my Postfix Server. Now I need to move to an Exchange: Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 that has POP3 and SMTP support enabled. I use actionmailer 1.2.5 and am not able to successfully login to the server while trying to send a mail. In case I use Mail.app sending and recieving works fine as long as I change the authentication schema to "Password". Checking the server looks like so: READ Nov 18 10:37:00.509

Rails 3.2 ActionMailer handle unsubscribe link in emails

时光总嘲笑我的痴心妄想 提交于 2019-12-08 05:43:45
问题 I have a list of customers that I send emails using an ActionMailer mailer. I am trying to code a link at the bottom of each email so a customer can unsubscribe from a mailing. So far I have an opted_out field in my customers database, I am simply unsure how to properly set up the route and have it update the correct database field. I want to design this so the user can simply click the link and viola, unsubscribed. in blast_mailer.rb def mail_blast(customer, blast) @customer = customer

UserMailer with Devise

假装没事ソ 提交于 2019-12-08 05:31:25
am using my custom mailer UserMailer to send emails. It works perfect in development, but in production i get error 500, that is when am trying to retrieve my password on forgetting. here is what is in the production logs in the production mode Processing by Devise::PasswordsController#create as HTML Parameters: {"utf8"=>"✓","authenticity_token"=>"xxxxxxxxxxxxxxx", "user"=>{"email"=>"sam@gmail.com"}, "commit"=>"Send me r$ Completed 500 Internal Server Error in 2ms NameError (uninitialized constant Devise::UserMailer): activesupport (3.2.8) lib/active_support/inflector/methods.rb:230:in `block

Rails 3 - action mailer SocketError getaddrinfo No such host is known

核能气质少年 提交于 2019-12-08 01:49:11
问题 I've configured the action mailer as per http://edgeguides.rubyonrails.org/action_mailer_basics.html My Outgoing Mail Server: mail.xxxx.com (server requires authentication) port 26 and i've the following configuration in config\environments\development.rb config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { :address => "mail.xxxx.com", :port => 26, :domain => 'xxxx.com', :user_name => 'dev@xxxx.com', :password =>

How to prevent style duplication in Rails HTML emails?

六月ゝ 毕业季﹏ 提交于 2019-12-07 20:06:43
问题 I am trying to build rails HTML emails, but the structure (header and footer) of the emails is duplicated in each one. Typically it's not a problem, but with the inline styles as well, it seems like it can be an issue if I want to change the color. How can I pull these elements out of each file and into one? Also, is there anyway to eliminate the duplication of text between the html.erb and text.erb files. 回答1: A simple way to do it is to reference a couple of partials. Let's say they're

Rails - setting multiple layouts for a multipart email with mailer templates

混江龙づ霸主 提交于 2019-12-07 18:39:21
问题 So Rails 2.2 added mailer layouts, which is great, except that I can't figure out how to make them work when I'm sending a multipart email..it's wrapping my mail content with the same layout for both the text/plain version and the text/html version. What I want is to wrap my layout around either only the text/html version, or to be able to have a separate layout for each. Anybody encountered this? I haven't seen any mention of it elsewhere, Cameron 回答1: For future reference the solution in

How do you use an instance variable with mailer in Ruby on Rails?

狂风中的少年 提交于 2019-12-07 13:59:20
问题 I created an instance variable (@user) in the model of a mailer and want to access it in the view? But it's giving me an an error (@user = nil). What's the best way to pass a variable to view (the email body)? Thanks, Chirag 回答1: If you want to access an instance variable in your mailer template then in your mailer model add @body[:user] = user_object The above would create an instance variable @user that can be accessed in your view. You should be able to access user object in your mailer

Allow user to create custom email template for ActionMailer in Rails

懵懂的女人 提交于 2019-12-07 12:43:10
问题 I want to allow the user of rails app to create their own email template via a form and use that as the sites standard email template form which mail will be sent but I can't find any tutorials, it also needs to contain a couple of dynamic variables. Is there a defined way of doing this? ( so the user would enter the email text in a form referencing variables that would be evaluated before being sent ) 回答1: There are many ways you can achieve it. Here is one way. First of all, you need to

Actionmailer - Sparkpost template and multilanguage

穿精又带淫゛_ 提交于 2019-12-07 08:30:36
问题 It's my first time setting up mails in a rails project. I was told to use SparkPost and to create templates for different languages for several actions. For simplicity lets say a user_signed_up(user) mail. Currently I have this setup working: Gem installed: 'sparkpost' mail.rb ActionMailer::Base.smtp_settings = { address: "smtp.sparkpostmail.com", port: 587, enable_starttls_auto: true, user_name: "SMTP_Injection", password: SPARKPOST_API_KEY, domain: 'foo-bar.com' } ActionMailer::Base