actionmailer

How to catch error exception in ActionMailer

拟墨画扇 提交于 2019-11-27 19:07:44
The problem is how can I catch exception in delivering mail by ActionMailer. For me it sounds impossible, because in this case ActionMailer should sent mail to mailserver, and if mailserver returns error, ActionMailer should show me this error. I am interested only in counting undelivered mails. Do you have any ideas how to implement this? Thanks! I'm using something like this in the controller: if @user.save begin UserMailer.welcome_email(@user).deliver flash[:success] = "#{@user.name} created" rescue Net::SMTPAuthenticationError, Net::SMTPServerBusy, Net::SMTPSyntaxError, Net::SMTPFatalError

gmail smtp with rails 3

不打扰是莪最后的温柔 提交于 2019-11-27 19:02:36
I am trying to get a confirmation email sending using a gmail account. I have looked around and there is nothing that is obvious. There is no errors or anything, it just dosn't send I have this as the initalizer: ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.perform_deliveries = true ActionMailer::Base.raise_delivery_errors = true ActionMailer::Base.smtp_settings = { :address => "smtp.gmail.com", :port => 587, :domain => "gmail.com", :user_name => "<address>@gmail.com", :password => "<password>", :authentication => "plain", :enable_starttls_auto => true } ActionMailer::Base

How to send emails with multiple, dynamic smtp using Actionmailer/Ruby on Rails

霸气de小男生 提交于 2019-11-27 18:12:34
I saw this post but mine is slightly different: Rails ActionMailer with multiple SMTP servers I am allowing the users to send mail using their own SMTP credentials so it actually does come from them. But they will be sent from the Rails app, so that means for each user I need to send their emails using their own SMTP server. How can I do that? Just set the ActionMailer::Base configuration values before each send action. smtp_config = user.smtp_configuration ActionMailer::Base.username = smtp_config.username ActionMailer::Base.password = smtp_config.password ActionMailer::Base.server = ..

How do I create a Mailer Observer

爱⌒轻易说出口 提交于 2019-11-27 17:50:31
I'd like to run some code whenever an email is sent on my app. As ActionMailer doesn't support after_filter, I would like to use an observer. The Rails docs mention this in passing, however does not elaborate. Thanks! I'm surprised how little there is in Rails' documentation about this. Basically, ActionMailer in Rails 3 introduces the use of Interceptors (called before the message is sent) and Observers (after the message is sent). To set up an Observer, add the following to an initializer: class MailObserver def self.delivered_email(message) # Do whatever you want with the message in here

undefined method `name' for “actionmailer”:String

£可爱£侵袭症+ 提交于 2019-11-27 17:36:24
问题 I've an old version of Rails project which was built using BrowserCMS in the config/environment file RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION so I installed this gems using rvm so I can run it $ gem list *** LOCAL GEMS *** actionmailer (2.3.8, 2.3.4) actionpack (2.3.8, 2.3.4) activerecord (2.3.8, 2.3.4) activeresource (2.3.8, 2.3.4) activesupport (2.3.8, 2.3.4) bundler (1.1.4) mysql (2.8.1) rack (1.1.3, 1.0.1) rails (2.3.4) rake (0.8.7) I run rake db:create it works fine,

Rails ActionMailer - format sender and recipient name/email address

安稳与你 提交于 2019-11-27 17:13:51
Is there a way to specify email AND name for sender and recipient info when using ActionMailer? Typically you'd do: @recipients = "#{user.email}" @from = "info@mycompany.com" @subject = "Hi" @content_type = "text/html" But, I want to specify name as well-- MyCompany <info@mycompany.com> , John Doe <john.doe@mycompany> . Is there a way to do that? James McKinney If you are taking user input for name and email, then unless you very carefully validate or escape the name and email, you can end up with an invalid From header by simply concatenating strings. Here is a safe way: require 'mail'

Sending mail with Rails 3 in development environment

Deadly 提交于 2019-11-27 16:55:50
I'm sure this has been asked a million times before but I can't find anything that works for me so I'm asking again! I just need a way of sending emails using ActionMailer in rails 3. I have followed numerous tutorials including the Railscasts tutorial on the new ActionMailer and I can see the mails being generated but I don't receive them. I have tried a bunch of different ways but they generally amount to configuring the following settings ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = { :address => "smtp.gmail.com", :port => "587", :domain => "gmail.com",

Rails attachments inline are not shown correctly in gmail

天涯浪子 提交于 2019-11-27 15:40:40
Can anyone point me to the problem? I'm using inline attachments in my rails 3.1 application mailer. The letter also contains images which are stored at amazon w3 servers. The problem is that gmail doesn't display the letter correctly. I have inline attachments in the letter. But Gmail shows these files as attached ones. The letter also contains an attached html page which contains the letter itself. All gmail displays is a set of symbols which i suppose to a base64 version of one of the attached images. See the screenshot. I can't post the image due to the lack of necessary amount of rating

ActionMailer not sending mail in development Rails 4

最后都变了- 提交于 2019-11-27 11:53:33
Why is this mailer not sending any mail? (Or any ideas for debugging?) In my_app/config/environments/development.rb I have this code: config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { address: 'smtp.gmail.com', port: 587, domain: 'my_app.com', user_name: ENV['GMAIL_USERNAME'], password: ENV['GMAIL_PASSWORD'], authentication: 'plain', enable_starttls_auto: true } Then on my local computer in ~/.bash_profile I have this code: export GMAIL_USERNAME='blah@my_app.com' export GMAIL_PASSWORD='***' When I run $ env in my terminal, I see that both environment variables

What is the right way to embed image into email using Rails?

天涯浪子 提交于 2019-11-27 11:52:48
What is the right way to embed an image into email using Rails? I combined the answer from Oksana with a custom helper approach and got the following to work quite nicely. app/helpers/email_helper.rb module EmailHelper def email_image_tag(image, **options) attachments[image] = File.read(Rails.root.join("app/assets/images/#{image}")) image_tag attachments[image].url, **options end end app/mailers/base_mailer.rb class BaseMailer < ActionMailer::Base add_template_helper(EmailHelper) end app/mailers/my_mailer.rb class MyMailer < BaseMailer def send_my_mail(email) mail to: email, subject: "My