Rails 邮件程序 Ubuntu

发布于 2024-12-21 08:17:42 字数 1189 浏览 4 评论 0原文

在我的 Rails 应用程序(在 Mac 上运行)中,我使用了一个名为 pony 的 gem。当我通过 pony 创建消息时,我得到以下输出(从 Rails 控制台输出)。

#<Mail::Message:2186559360, Multipart: false, Headers: <Date: Tue, 13 Dec 2011 00:15:14 -0500>, <From: [email protected]>, <To: [email protected]>, <Message-ID: <[email protected]>>, <Subject: nothing>, <Mime-Version: 1.0>, <Content-Type: text/plain>, <Content-Transfer-Encoding: 7bit>>

此消息发送没有问题。

对于在 Ubuntu 上运行的单独应用程序,pony 会抛出错误。

我没有发布错误,因为我切换到了一个名为 mail 的 gem,它在发送消息后给出了相同的输出(没有错误,控制台说它发送得很好)。但问题是Ubuntu系统上没有消息发送。

我怀疑这是因为我从未在 Ubuntu 系统上设置过邮件系统(如果这是编程世界中需要完成的操作)。如果是,我不确定应该如何执行此操作,以便发送我的邮件。

我正在使用 Rails 3 和 Ubuntu Oneiric Ocelot。

In my rails application (running on a mac), I'm using a gem called pony. When I create a message through pony I get the following output (out of a rails console).

#<Mail::Message:2186559360, Multipart: false, Headers: <Date: Tue, 13 Dec 2011 00:15:14 -0500>, <From: [email protected]>, <To: [email protected]>, <Message-ID: <[email protected]>>, <Subject: nothing>, <Mime-Version: 1.0>, <Content-Type: text/plain>, <Content-Transfer-Encoding: 7bit>>

This message sends without problem.

For a separate application, running on Ubuntu, pony throws me errors.

I didn't post the errors, because I switched to a gem called mail which gives the same output after sending a message (no errors, the console says it sent fine). But the problem is that no message get sent on the Ubuntu system.

I suspect it's because I've never set up a mailing system on the Ubuntu system (if that's an action that ever needs to be done in the programming world). If it is, I'm not sure how I should do this, so that my mail will get sent.

I'm using rails 3 and Ubuntu Oneiric Ocelot.

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

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

发布评论

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

评论(2

找回味觉 2024-12-28 08:17:42

您可以使用外部 SMTP 服务器,而不是依赖操作系统来运行本地 sendmail(OS X 可以,但我猜您的 Ubuntu 不可以)。

对于测试和开发,您的 Gmail 可以正常工作:

Pony.mail(:to => '[email protected]', :via => :smtp, :via_options => {
  :address              => 'smtp.gmail.com',
  :port                 => '587',
  :enable_starttls_auto => true,
  :user_name            => 'user',
  :password             => 'password',
  :authentication       => :plain, # :plain, :login, :cram_md5, no auth by default
  :domain               => "localhost.localdomain" # the HELO domain provided by the client to the server
})

如果您从生产应用程序发送电子邮件,则可以使用 中的廉价外部 SMTP 服务器http://sendgrid.com/

Instead of relying on the operating system to have a working local sendmail (which OS X does, but I guess your Ubuntu doesn't), you could use an external SMTP server.

For testing and development, your Gmail will work:

Pony.mail(:to => '[email protected]', :via => :smtp, :via_options => {
  :address              => 'smtp.gmail.com',
  :port                 => '587',
  :enable_starttls_auto => true,
  :user_name            => 'user',
  :password             => 'password',
  :authentication       => :plain, # :plain, :login, :cram_md5, no auth by default
  :domain               => "localhost.localdomain" # the HELO domain provided by the client to the server
})

If you're sending emails from a production app, you could use an inexpensive external SMTP server from http://sendgrid.com/.

豆芽 2024-12-28 08:17:42

进入ubuntu软件中心。搜索

mail agent

(您需要的是邮件传输代理)

现在应该有一个叫做“mutt”的东西了。安装它。 (当我遇到这个问题时,它对我有用)

Go to ubuntu software center. Search for

mail agent

(what you need is a mail transfer agent)

now something called 'mutt' should be there. Install it. (it worked for me when i had this problem)

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