What's the benefit of using mailman gem over ActionMailer? - ruby-on-rails

I'm trying to understand what the benefit is here; the only I can see is avoiding a rails bootstrap every time an email is received, but I imagine this is possible with ActionMailer as well with a bit of set up. Any help would be very useful.
Chris.
http://rubygems.org/gems/mailman

The benefit is to avoid the Rails overhead, and it provides some syntax sugar. Also to avoid having to write it yourself.
The fact is though that the underpinnings of the Mailman Micro-framework are essentially the same as ActionMailer the Mail gem. You can achieve the same results using ActionMailer or just Mail without the added dependencies. It just really depends on your use case, and how much you want to write yourself.

Related

Rails 4 with minimum dependencies

I'm writing a Rails 4 app from scratch and I want it to be as independent as possible. For example, if I'm writing an authorization code, I don't want to use bcrypt gem.
So what are the absolute essential gems for Rails to work visually and technically?
As an example, I'd just like to create a simple scaffold user first_name last_name that I can see on my browser and make simple create, read, update, destroy operations from the browser.
The rails 4 app comes bundled with a lot of gems. Most of them are very good things to keep, but if you really care about it:
rails - That should be self explanatory.
sqlite3 - You need a database gem. Personally I use mysql, but it's totally up to you and the comparisons are beyond the scope of this question.
sass-rails - this is used in precompiling assets from stylesheets. Sass provides a lot of nice utilities, including the ability to nest CSS rules that make your stylesheets both more readable and maintainable, but if you don't want it, you don't need it.
uglifier - if you don't care about sending minified JS (as in you don't care about the size of your request responses) you can get rid of this. I definitely wouldn't recommend that though.
coffee-rails - if you don't want to use coffee script you can get rid of this.
jquery-rails - most modern sites use some kind of javascript library, be it jquery, prototype, angular, Node.js, or something else. It's up to you, but I would at least use something.
turbolinks - rails 4 by default uses javascript to load each page, which speeds up the page load time significantly. You need to read more here if you're going to get rid of this.
jbuilder - if you don't care about responding with jsons, you can get rid of this (definitely don't recommend)
sdoc - if you don't want documentation, you can remove it.
capistrano - this is for helping with deployment, and I would suggest using it.

Need an HTTP gem for rails

I'm not pleased with Net::HTTP at all, and I'm looking for a lightweight gem that will either replace that library or at the very least hide it from me.
Does anyone have any suggestions?
My vote goes to HTTParty. It's incredibly simple to use and can be as powerful as you choose. Here's a code sample:
HTTParty.get("http://maps.googleapis.com/maps/api/distancematrix/json?origins=New+York+NY&destinations=Los+Angeles+CA&mode=car&language=en&sensor=false")
Pretty simple stuff depending on what you're using it for.
Try the RestClient gem:
https://github.com/archiloque/rest-client
There are a few out there.
Ruby toolbox has a http client list: http://ruby-toolbox.com/categories/http_clients.html
Personally I usually use HTTParty... or sometimes Mechanize, it's good for submitting forms
I would recommend checking the docs of each, to see which one suits your purpose best.
Hope this helps.
You might want to check out the rest gem, it was created and tested so we could find the best performing http gems by wrapping those gems and creating a standard interface to them. Turns out HTTParty and RestClient are very slow gems so I wouldn't recommend those, although you can always swap out the underlying gem in rest to see for yourself without having to change your code (other than initialization). rest gem by default will be much, much faster.
It's also very easy to use:
#rest = Rest::Client.new()
#rest.get(url, options...)
More info: https://github.com/iron-io/rest

How do I test ActionMailer?

I am using ActionMailer for the first time. It becomes a chore having to go into the development.log to and check if they are going, and I would like to write an automated test. What is the best/most practical solution for testing ActionMailer emails on Rails?
You can try the email-spec gem. It's really good and you can test a lot of stuff with it.

Difference between ActiveMailer and Mail gem?

In ruby on rails 3 you can use their ActiveMailer for sending emails.
Also you can install the Mail gem.
I wonder what the difference is?
Does the Mail gem provide things ActiveMailer doesnt?
Should i always install this gem?
Thanks
The relationship between the two is that the Mail gem is how Rails 3 implements mail ( replacing the previous TMail approach in earlier versions). In other words, ActionMailer is the Rails wrapper around the Mail gem's usage within the framework.
From a post by the gem's author:
The prior versions of ActionMailer used TMail for all its email delivery needs, and because certain functionality was missing in TMail (such as auto quoting and encoding of fields, handling multipart emails smoothly, etc.), ActionMailer had grown a set of fairly complex and fragile methods to shoehorn in the missing functionality.
That post is here. And this screencast might be helpful if you haven't seen it already.

Simplest way to send mail with Ruby on Rails

What is the simplest way to send mail using Ruby on Rails? Is there a way to send mail directly via ruby and skip all the rails models and complexity, just like php's mail() function?
Thanks for your help.
The simplest way in plain old ruby is to use net/smtp. However rails has it's own built in mailing facilities, because sending mail is something that is pretty common. The best way to do it in rails, is to use a Mailer model
Make sure you replace all the example.com's with real values:
require 'net/smtp'
Net::SMTP.start('smtp.example.com', 25) do |smtp|
smtp.send_message "Subject: testing from ruby", 'from-address#example.com', ['to-address1#example.com', 'to-address2#example.com']
end
There's also TMail.
Another excellent solution is a gem called pony. It is exactly like php's mail() function. Simply and easy.
yes check out the ruby docs...http://ruby-doc.org/stdlib/
the package you want to look at is net/smtp
there is also
http://www.rfc20.org/rubymail/(ruby mail)
which is popular and make it a little easier
I'm concerned that if you don't want to use ActionMailer that maybe you just don't get rails. ActionMailer makes sending email with good templating and the like very very easy, you really should look into it.

Resources