actionmailer

Ruby on Rails-Action mailer no as per desired?

霸气de小男生 提交于 2019-12-06 15:46:13
问题 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

Sending mails automatically through action mailer Rails 3.1

纵饮孤独 提交于 2019-12-06 13:06:09
问题 I have to send weekly emails to all the user about the latest things happening. I am using ActionMailer to accomplish other mailing task however I have no clue how to automate the weekly emails. Update I found whenever gem which could be used to schedule cron jobs. I guess this could be used to send weekly emails which I intend to. Still looking how to make it work with ActionMailer will update once I find the solution Update 2 This is what I have done so far using whenever gem:- in schedule

How to modify actionmailer email html_part before sending

﹥>﹥吖頭↗ 提交于 2019-12-06 11:29:23
I have everything at the point where I'm about to send out the email but I need to modify all links to include Google Analytics attributes. The problem is that if I try and read/write the html_part.body of the email, the entire html string somehow becomes encoded and doesn't display the email properly (i.e. <html> becomes <html> ). I have logged the html_part.body.raw_source in the logger and it shows as proper unencoded HTML, it's only when the email is actually sent does the encoding occur. EBlast.rb (ActionMailer) def main(m, args={}) # Parse content attachment references (they don't use

Action Mailer Configuration for Gmail

牧云@^-^@ 提交于 2019-12-06 10:02:59
问题 I'm trying to add e-mail delivery with Gmail SMTP to my app. I've already done the "less secure apps" way before but I don't want to use this option in this project. I've tried to look into Google's documentation or some gem to make it work, but to no avail. Everyone just sends some code (like below, which is usually the same I have) or tells me to try 'less secure app'. My current action mailer configuration on production.rb is: config.action_mailer.perform_caching = false config.action

How to intercept ActionMailer's messages on rails 3?

筅森魡賤 提交于 2019-12-06 09:01:17
问题 I'm trying to intercept messages in my rails (3.0.10) app to modify the body. While I was able to find some info about how to do that, it seems something has changed and now using the old methods no longer work. I use a code that looks like this: class Hook def self.delivering_email(message) message.subject = 'Hook changed the subject' end end ActionMailer::Base.register_interceptor(Hook) After sending an email, the subject doesn't get changed! I also found a tweet that indicates that

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

烈酒焚心 提交于 2019-12-06 06:37:19
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 => 'dev123', :authentication => 'login', # :enable_starttls_auto => true } But I always get the error

Receiving and Processing Email: Heroku, Sendgrid, and possibly Mailman

匆匆过客 提交于 2019-12-06 06:16:17
My app creates a unique email for each user, and users send email to that address for processing. Using Sendgrid, I've piped incoming emails to my domain (hosted on Heroku) to an address: site.com/receive_email I use the TO field to determine the user, since the email address is randomly generated. I've experimented using an external script like Mailman , but since I'm hosted on Heroku I'd need to have a worker running full time to keep this process going. Not really looking for that at the moment for this test app. That leaves processing it as a POST request. I have access to POST hash

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

て烟熏妆下的殇ゞ 提交于 2019-12-06 06:12:33
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 For future reference the solution in the blog post above amended in a second blog post is given below all credit to the above mentioned blog post.

Allow user to create custom email template for ActionMailer in Rails

二次信任 提交于 2019-12-06 02:55:31
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 ) There are many ways you can achieve it. Here is one way. First of all, you need to store user-generated email templates in a database. CustomEmailTemplate.create(user_id: params[:user_id],

Rpsec tests failed with 'rspec' but not with 'rspec path_of_the_file'

梦想与她 提交于 2019-12-06 02:23:08
If I run this command "rspec ./spec/requests/api/v1/password_reset_request_spec.rb" all the test inside this file pass. However when I run "rspec" I've a faillure on the tests inside this file. 1) /api/v1/password_reset #request when the email match with a runner when there is no request pending create a token for reset the password Failure/Error: post("/api/v1/password_reset/request", @params) NoMethodError: undefined method `reset_password' for RunnerMailer:Class # ./app/services/password_manager.rb:35:in `reset_password' # ./app/controllers/api/v1/password_reset_controller.rb:31:in `request