2011-09-08 41 views
0

西納特拉1.2.6/3.1.2 Haml的小馬發送電子郵件HAML與小馬

我收到 「錯誤號碼參數錯誤的(0 1)」,它指向

西納特拉/ base.rb

def haml(template, options={}, locals={}) 
    render :haml, template, options, locals 
end 

我送:HTML_BODY =>(HAML:html_email)小馬

任何幫助將非常感謝!

M.

回答

1

您的代碼似乎在Sinatra 1.2.6,Haml 3.1.3和Pony 1.3中工作。 雖然我會用HAML(:測試),而不是(HAML:測試)

test.rb:

require 'rubygems' 
require 'sinatra' 
require 'pony' 
require 'haml' 

set :views, Proc.new { root } 

get '/send' do 
    options = { 
    :to => '[email protected]', 
    :from => '[email protected]', 
    :subject => 'Test', 
    :body => 'Test Text', 
    :html_body => (haml :test), 
    :via => :smtp, 
    :via_options => { 
     :address => 'smtp.gmail.com', 
     :port => 587, 
     :enable_starttls_auto => true, 
     :user_name => 'login', 
     :password => 'password', 
     :authentication => :plain, 
     :domain => 'HELO' 
    } 
    } 

    Pony.mail(options) 
end 

test.haml:

!!! 
%html 
    %head 
    %meta{ :content => "text/html; charset=utf-8", :"http-equiv" => "Content-Type" } 
    %title Test 
    %body 
    %h1 Test 
    %p Test content