Irbis
Irbis

Reputation: 11

RUBY: Pony email attachment error

 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)}
    )

File comes unreadable, distorted (modified version of pdf file does not solve the problem 1.4-1.6).. What's wrong?? Wrong mime type??

Upvotes: 1

Views: 884

Answers (2)

Evan
Evan

Reputation: 3306

content-type shouldn't be plain. Let pony figure it out for you (multipart)

Upvotes: 0

maxnk
maxnk

Reputation: 5745

Looks like encoding-related issue. Try to use File.binread instead.

Upvotes: 1

Related Questions