使用 Pony Gem 在 Ruby 中发送带有附件的电子邮件

发布于 2024-10-20 08:51:22 字数 1204 浏览 12 评论 0原文

我正在编写一个脚本,该脚本将向一系列人员发送电子邮件,并且该电子邮件将包含一个附件。

我一直遇到这个问题:
/usr/local/lib/ruby/1.9.1/net/smtp.rb:942:in 'check_response': 552 抱歉,邮件大小超出了我的数据字节限制 (#5.3.4) (Net::SMTPFatalError )

附件只有 110kb

代码:

    Pony.mail(
        :to => to,
        :from => 'Me <[email protected]>',
        :subject => html_entity_decoder.decode(options[:subject]),
        :html_body => "#{options[:body]}".html_safe,
        :attachments => {File.basename("#{attachment}") => File.read("#{attachment}")},
        :headers => { "Content-Type" => "multipart/mixed", "Content-Transfer-Encoding" => "base64", "Content-Disposition" => "attachment" },
        :via => :smtp, 
        :via_options => {
          :address        => ADDRESS,
          :port           => '25',
          :enable_starttls_auto => true,
          :user_name      => USERNAME,
          :password       => PWD,
          :authentication => :plain,
          :domain         => DOMAIN
          }
      )

知道什么可能是错误的吗?

I am writing a script that is going to be sending out emails to a list of people and with this email there is going to be an attachment.

I keep running into this issue:
/usr/local/lib/ruby/1.9.1/net/smtp.rb:942:in 'check_response': 552 sorry, that message size exceeds my databytes limit (#5.3.4) (Net::SMTPFatalError)

The attached file is only 110kb

Code:

    Pony.mail(
        :to => to,
        :from => 'Me <[email protected]>',
        :subject => html_entity_decoder.decode(options[:subject]),
        :html_body => "#{options[:body]}".html_safe,
        :attachments => {File.basename("#{attachment}") => File.read("#{attachment}")},
        :headers => { "Content-Type" => "multipart/mixed", "Content-Transfer-Encoding" => "base64", "Content-Disposition" => "attachment" },
        :via => :smtp, 
        :via_options => {
          :address        => ADDRESS,
          :port           => '25',
          :enable_starttls_auto => true,
          :user_name      => USERNAME,
          :password       => PWD,
          :authentication => :plain,
          :domain         => DOMAIN
          }
      )

Any idea on what could be wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

云雾 2024-10-27 08:51:22

这表明您要发送邮件的邮箱空间不足。

该错误是 SMTP 错误:
存储分配

552 请求的邮件操作已中止:超出了rfc http://www.ietf.org/ 中概述的 rfc/rfc2821.txt

因此,要么邮箱已满,要么您正在发送无法放入其中的内容

This is telling you that the mailbox you are sending it to, has run out of space.

The error is an SMTP error :
552 Requested mail action aborted: exceeded storage allocation

outlined in the rfc http://www.ietf.org/rfc/rfc2821.txt.

So either the mail box is full or you are sending something that will not fit in it

客…行舟 2024-10-27 08:51:22

请使用这个

:attachments => {File.basename("#{attachment}") => File.read("#{attachment}")},
  :headers => { "Content-Type" => "multipart/mixed", "Content-Transfer-Encoding" => "base64", "Content-Disposition" => "attachment" }

也许这会解决你的问题。

Please use this

:attachments => {File.basename("#{attachment}") => File.read("#{attachment}")},
  :headers => { "Content-Type" => "multipart/mixed", "Content-Transfer-Encoding" => "base64", "Content-Disposition" => "attachment" }

Probably this will solve your problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文