我在 ruby 脚本中压缩了几个文件。附件之前所有文件的总大小几乎为 12 MB,压缩后结果文件的大小几乎为 8.3 MB,即 Attachment.zip。我使用 actionmailer 作为附件发送此文件,如下所示:
attachments[file_name] = File.read(path_of_the_file)
receivers = ["<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bcddfcde92dfd3d1" rel="noreferrer noopener nofollow">[email protected]</a>", "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1a785a7934797577" rel="noreferrer noopener nofollow">[email protected]</a>"]
mail(:to => receivers, :subject => subject, :body => "").deliver
但问题是它不断给出错误554 Message returned: Stream is more more than 10485760 bytes long.当我在压缩之前单独发送文件时,它给出了相同的错误。我不知道如何解决这个问题。因此,如果有人帮助解决这个问题,我将非常感激。
最佳答案
该消息被您的应用连接到的服务器拒绝。
要么让您的邮件小于 10485760 字节,要么使用没有该限制的其他服务器来发送邮件。
关于ruby-on-rails - 在 Ruby on Rails 中将 zip 文件作为附件发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20994590/