What is the best way to make a newsletter in rails3

Is there a gem to do this, and if not, what is the best approach. I assume that I will store emails in the mailing list database, and I need a form that will email everyone at once. thanks!

+7
source share
3 answers

No stone for this that I know of.

In fact, due to processing problems, the best way would be to use an external email service provider through an API provider.

However, creating your own distribution system is no different from creating your regular MVC. Only add-ons are mailing lists and mailing lists.

(1) So, you create a model that deals with registration data (: name ,: email ,:, etc.) and a model that deals with the newsletter itself.

(2) The controller that deals with it (CRUD) + (: send). Each recipient sends, sends data to the email program that creates the email, and then sends it.

def send @newsletter = Newsletter.find(:params['id']) @recipients = Recipient.all @recipients.each do |recipient| Newsletter.newsletter_email(recipient, @newsletter).deliver end end 

(3) Mailer creates an email, makes changes to each email, if you want to do something like this and return it to the controller’s action to send for delivery.

 class Newsletter < ActionMailer::Base default :from => " my_email@example.com ", :content_type => "multipart/mixed" def newsletter_email(recipient, newsletter) # these are instance variables for newsletter view @newsletter = newsletter @recipient = recipient mail(:to => recipient.email, :subject => newsletter.subject) end end 

(4) Ofc, you need email program views that look like regular views. Well, in multipart there is:

  • newsletter_email.html.erb (or haml)
  • newsletter_email.txt.erb

    If you want to send both html and text messages. Instance variables are defined in mailbox c.

And ... that’s all. Well, you can use lazy work to send them, since sending more than a few hundred letters may take some time. Several ms times n can be a lot of time.

Good luck.

+12
source

Please check maktoub gem , there is a blog post above it.

+3
source

No gem that I don't know about either, and based on @Krule's answer, here is a screencast of setting up email programs in Rails.

How to create, view and send emails from your rails application

I was looking for something similar when I found this. I think that with a little tweaking, it can be easily used to create emails.

Save money! Spend somewhere else.

0
source

All Articles