Thursday, 15 July 2010

ruby - sending file with pony by sinatra app - missing file -



ruby - sending file with pony by sinatra app - missing file -

i want send email sinatra application.

here code:

require 'pony' class cms < application "/mail" pony.mail :to => 'to@gmail.com', :from => "from@gmail.com", :subject => "thanks signing guestbook!", :via => :sendmail, :via_options => { :address => 'smtp.gmail.com', :port => '587', :user_name => 'user@gmail.com', :pass => 'pass', :enable_starttls_auto => false }, :body => erb(:"cms/mail") redirect '/' end end`

thin starting application no errors, when request myapp.local/mail i've got error:

loaderror - no such file load -- mail/network/delivery_methods/smtp: /var/lib/gems/1.8/gems/mail-2.4.4/lib/mail/configuration.rb:31:in lookup_delivery_method' /var/lib/gems/1.8/gems/mail-2.4.4/lib/mail/configuration.rb:25:in delivery_method' /var/lib/gems/1.8/gems/mail-2.4.4/lib/mail/mail.rb:111:in delivery_method' /var/lib/gems/1.8/gems/mail-2.4.4/lib/mail/message.rb:116:in initialize' /var/lib/gems/1.8/gems/mail-2.4.4/lib/mail/mail.rb:50:in new' /var/lib/gems/1.8/gems/mail-2.4.4/lib/mail/mail.rb:50:in new' /var/lib/gems/1.8/gems/pony-1.4/lib/pony.rb:174:in build_mail' /var/lib/gems/1.8/gems/pony-1.4/lib/pony.rb:138:in mail' ./app/controllers/cms.rb:8:in /mail'

file /var/lib/gems/1.8/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb exists.

i getting same error when using inline configuration of mail service gem:

mail.delivery_method :sendmail mail.deliver!

removing first line, , moving configuration next loading of mail service gem fixed it.

wherever in app require 'mail' configure immediately:

require 'mail' mail.defaults delivery_method :sendmail end

update: worked awhile... reason began seeing error: rbenv/versions/1.8.7-p374/lib/ruby/gems/1.8/gems/mail-2.5.4/lib/mail/fields/common/common_address.rb:9:in `parse': no such file load -- mail/elements/address_list (loaderror)

update2: failures happen randomly seems. way autoload works in ruby 1.8.7-p374 causing not able find files in fact exist. also, using slimgems not rubygems.

these hacks i've had implement far utilize mail service multi-part email , sendmail delivery method:

require 'mail' require 'mail/network/delivery_methods/sendmail' require 'mail/elements/address_list' require 'mail/fields/common/common_address' require 'mail/elements/content_type_element' require 'mail/elements/address' require 'mail/elements/content_transfer_encoding_element' mail.defaults delivery_method :sendmail end

ruby sinatra pony

No comments:

Post a Comment