ruby 在Rails中发送外发邮件正文中的附件文件

wtzytmuj  于 2023-02-18  发布在  Ruby
关注(0)|答案(1)|浏览(205)

我尝试在邮件正文中发送S3 url文件,但收到错误

Errno::ENOENT: No such file or directory @ rb_sysopen

我想要这样的东西,但我无法实现这一点

@path = s3_url
attachments["output.pdf"] = {
  mime_type: "application/pdf",
  content: HTTParty.get(@path).response.try(:body)
}
mail(to: 'xyz@gmail.com', subject: "Test Attchment", body: File.read(URI.parse(@path)))
jc3wubiy

jc3wubiy1#

使用Net::HTTP或HTTPary获取PDF并读取响应以在邮件程序中设置附件。
试着这样做:

# change the file name if required
mail.attachments["output.pdf"] = {
  mime_type: "application/pdf",
  content: HTTParty.get(s3_path).response.try(:body)
}

相关问题