RUBY:小马电子邮件附件错误
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)..出了什么问题?哑剧类型错误??
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??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来像是与编码相关的问题。
尝试使用 File.binread 代替。
Looks like encoding-related issue.
Try to use File.binread instead.
内容类型不应该是简单的。让小马帮你解决(多部分)
content-type shouldn't be plain. Let pony figure it out for you (multipart)