actionmailer

Ruby mailer is coming up with an EOFError

ぃ、小莉子 提交于 2019-11-30 14:32:41
问题 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 and this site was suggested. Please help. def contact @title= "Contact Us" if request.post? @message= Message.new(params[:contact]) if @message.valid? UserMailer.deliver_message( :message => @message ) flash[:notice] = "Thank you for contacting us"

How to render rails mailer views in Mailgun HTTP API

夙愿已清 提交于 2019-11-30 13:28:08
I'm using Mailgun HTTP API to send emails from rails application.But I'm not able to render the mailer views. This is my mailer class. class MailgunMails < ActionMailer::Base def send_complex_message data = Multimap.new data[:from] = "Excited User <postmasters@#{@@domain}>" data[:to] = "alice@example.com" data[:subject] = "Hello" data[:html] = File.open("#{Rails.root}/app/views/mailgun_mails/send_complex_message.html.erb", 'r').to_s.html_safe ## also tried data[:html] = render(template: "send_complex_message.html.erb") response = RestClient.post "https://api:#{@@private_key}"\ "@api.mailgun

asset_url in mailer on rails 3.1

别等时光非礼了梦想. 提交于 2019-11-30 13:27:06
问题 I have my mailer on rails 3.1 which has an inline attachment. To open that attachment i use this code: attachments["rails.png"] = File.read("#{Rails.root}/app/assets/images/Rails.png") is there a way to change that with something like assets_url ? 回答1: If I understand correctly, you want to use the asset pipeline's search functionality to locate the local path for a given asset so you don't have to hard-code which directory it's in. If that's the case, you want to do this: <YourAppName>:

How to Integrate 'premailer' with Rails

两盒软妹~` 提交于 2019-11-30 12:54:39
How does one integrate the ' premailer ' gem with a Rails (3.0.7) project? I currently have in my mailer: def welcome(user) @user = user mail to: user.email, subject: "Welcome" end But I can't figure out how to integrate the library. I need to call: premailer = Premailer.new(html) html = premailer.to_inline_css However, I'm not sure how to access the contents of my email from a mailer action. Try: def premailer(message) message.text_part.body = Premailer.new(message.text_part.body.to_s, with_html_string: true).to_plain_text message.html_part.body = Premailer.new(message.html_part.body.to_s,

Rails 3 -Render PDF from view and attach to email

给你一囗甜甜゛ 提交于 2019-11-30 12:49:37
问题 I have been using Wicked_pdf to render a view as a PDF and actionmailer to send emails, but I can't get them to work together. I want to attach a PDF version of a certain view to an email using actionmailer and send it out by clicking a link or a button. I have a link_to command that sends out an email. Here is my controller that gets the email generated: def sendemail @user = User.find(params[:id]) Sendpdf.send_report(@user).deliver redirect_to user_path(@user) flash[:notice] = 'Email has

Rails - Mail, getting the body as Plain Text

六月ゝ 毕业季﹏ 提交于 2019-11-30 10:19:29
问题 Given: message = Mail.new(params[:message]) as seen here: http://docs.heroku.com/cloudmailin It shows how to get the message.body as HTML, how to do you get the plain/text version? Thanks 回答1: The code above: message = Mail.new(params[:message]) will create a new instance of the mail gem from the full message. You can then use any of the methods on that message to get the content. You can therefore get the plain content using: message.text_part or the HTML with message.html_part These methods

rails email error - 530-5.5.1 Authentication Required.

时光总嘲笑我的痴心妄想 提交于 2019-11-30 09:23:47
问题 trying to send email form Ruby on Rails but getting this: SocketError in UsersController#create getaddrinfo: nodename nor servname provided, or not known My environments/development.rb file has: config.action_mailer.smtp_settings = { address: "smtp.gmail.com", port: 587, domain: "my_company.org", authentication: "plain", enable_starttls_auto: true, user_name: "my_username@my_company.org", password: "my_pass" } and config.action_mailer.delivery_method = :smtp and config.action_mailer.default

asset_url in mailer on rails 3.1

自古美人都是妖i 提交于 2019-11-30 07:13:39
I have my mailer on rails 3.1 which has an inline attachment. To open that attachment i use this code: attachments["rails.png"] = File.read("#{Rails.root}/app/assets/images/Rails.png") is there a way to change that with something like assets_url ? If I understand correctly, you want to use the asset pipeline's search functionality to locate the local path for a given asset so you don't have to hard-code which directory it's in. If that's the case, you want to do this: <YourAppName>::Application.assets.find_asset('Rails.png').pathname This will locate the asset using standard pipeline/sprockets

Set the Message-ID mail header in Rails3 / ActionMailer

流过昼夜 提交于 2019-11-30 06:47:40
I would like to alter the Message-ID header that is in the header portion of an email sent from a Ruby on Rails v3 application using ActionMailer. I am using Sendmail on localhost for mail delivery. Do I configure this in Sendmail or ActionMailer? Where do I configure this (if it is ActionMailer): a file in config/ folder or a file in app/mailers/ folder? Teddy's answer is good, except that if you actually want each message to have a different ID, you need to make the default a lambda. In the first block of code in his answer, it calculates the message-ID once, at init, and uses the same one

How do I configure the hostname for Rails ActionMailer?

拟墨画扇 提交于 2019-11-30 04:46:03
I'm working on a fairly traditional forgot password email - I want to email the user a password change token embedded in a link that they can click on in order to change their password. I'm emailing via the traditional ActionMailer. If I use a normal link_to tag <%= link_to "click here", :controller => foo, :action => 'bar', :token => token %> I get a relative link - rather useless from an email. If I add in :only_path => false , then it errors saying I need to set default_url_options[:host] . The ActionController docs imply that you do that by overriding the #default_url_options methods in