2011-09-08 166 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