2010-12-09 196 views
1
Pony.mail(:to => ad.to_s, :via => :smtp, :via_options => { 
    :address    => 'smtp.gmail.com', 
    :port     => '587', 
    :enable_starttls_auto => true, 
    :user_name   => 'login', 
    :password    => 'pass', 
    :authentication  => :plain, # :plain, :login, :cram_md5, no auth by default 
    :domain    => "localhost.localdomain", # the HELO domain provided by the client to the server 
    :headers => { 'Content-Type' => 'text/plain' }, 
    },:subject => 'detail', 
    :body     => IO.read('body.txt'), 
    :attachments => {"file.pdf" => File.read("./pdf/" + at.to_s)} 
    ) 

文件變得不可讀,扭曲(修改後的pdf文件版本不能解決問題1.4-1.6)。什麼是錯?錯誤的MIME類型??RUBY:Pony電子郵件附件錯誤

回答

1

看起來像編碼相關的問題。 嘗試使用File.binread來代替。

0

content-type不應該是plain。讓小馬爲你弄明白(多部分)