Rails Mailer Ubuntu

In my rails app (runs on mac), I use a gem called a pony. When I create a message through a pony, I get the following output (from the 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 is sent without problems.

For a standalone application running on Ubuntu, pony gives me errors.

I did not post errors, because I switched to a gem called mail, which gives the same result after sending the message (no errors, the console says that it was sent perfectly). But the problem is that no message is sent to the Ubuntu system.

I suspect this because I have never set up a mail system on an Ubuntu system (if this is an action that should ever have been done in the programming world). If so, I'm not sure how to do this so that my mail is sent.

I am using rails 3 and Ubuntu Oneiric Ocelot.

+4
source share
2 answers

Go to the ubuntu software center. Search

 mail agent 

(you need a mail transfer agent)

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

+1
source

Instead of relying on the operating system to have a working local sendmail (which OS is X, but I think your Ubuntu does not), you can 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 send emails from a production application, you can use a low-cost external SMTP server from http://sendgrid.com/ .

+1
source

Source: https://habr.com/ru/post/1386221/


All Articles