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: you@me.com>, <To: myself@hotmail.com>, <Message-ID: <4ee6df6288e90_30b080443b3c8148e@My-Name-MacBook-Pro.local.mail>>, <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.

有帮助吗?

解决方案

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)

其他提示

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 => 'you@example.com', :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/.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top