Haml and Google SMTP for email

I first thought that I would have to use ERB to render non-HTML-like templates. Not true. Haml let you do a :plain filter which is pretty much the same as using ERB templates.

Here’s a simple example haml template for email:

1
2
3
4
5
6
:plain
  Welcome #{@user.username} to Fund-A-Stache! 
 
  click the following link to activate your account:
 
  #{activation_link(@user)}

I’m also using Google SMTP for email. That way I can send email from my home (which blocks SMTP traffic). This may change, but just so I can remember why I’m doing this, here’s the Pony call:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Pony.mail(
  :to=>@user.email, 
  :from=>'user@example.org', 
  :subject=>'Welcome', 
  :body=>(haml :registration_email, :layout=>false),
  :content_type=>'text/html',
  :via=>:smtp,
  :smtp=>{
    :host=>'smtp.gmail.com',
    :port=>'587',
    :tls=>true,
    :user=>'user@example.org',
    :password=>'secret',
    :auth=>:plain, # :plain, :login, :cram_md5, no auth by default
    :domain=>"example.org" # the HELO domain provided by the client to the server
  }
)
Posted: March 13th, 2010 | Author: jay | Filed under: Code | Tags: , , , , , , | No Comments »

Using haml for view templates, ERB for email templates…

and I’m not sure how I feel about this. Maybe I should use Mustache for tempting because this whole thing is for moustaches…

Posted: March 10th, 2010 | Author: jay | Filed under: Code | Tags: , , , , , | No Comments »