Posts

Showing posts from September, 2009

Sending Email Using Gmail and Action Mailer

I've used this for a new site , which I'll be mentioning very soon. It took me quite some time to figure out and get right. The first thing to do is download the smtp_tls.rb file. I saved it in my Sinatra app, under lib . Next create a file called mailer.rb in the same lib directory with the following contents: require 'lib/smtp_tls' require 'action_mailer' class Mailer < ActionMailer::Base def my_email(from_email, from_name, message) recipients "marktucks@gmail.com" from from_email subject "Contact from " + from_name body :name => from_name, :email => from_email, :message => message end end Mailer.template_root = File.dirname(__FILE__) Mailer.delivery_method = :smtp Mailer.smtp_settings = { :address => "smtp.gmail.com", :port => "587", :domain => "YOUR_DOMAIN", :authentication => :plain, :enable_starttls_auto => true, :user_name =&