質問

I'm trying to send emails via sendmail in Padrino. I did the configuration specified here (Configuration and Quick Usage)

But I always get the following error in the server log (on Heroku or localhost):

app[web.1]: sh: Illegal option - 
app[web.1]: Errno::EPIPE - Broken pipe:

I installed the mail gem and I'm using Padrino 0.10.7

I'm using this, to send the email:

post :create do
  email(:from => "tony@reyes.com", :to => "john@smith.com", :subject => "Welcome!", :body=>"Body")
end

That's practically all I have...

役に立ちましたか?

解決

You should be using one of the parter addons for sending mail with Heroku.

A good option is Sendgrid

heroku addons:add sendgrid:starter --app=your_app_name

Then in your Padrino app in app.rb inside your App class:

set :delivery_method, :smtp => { 
  :address              => "smtp.sendgrid.net",
  :port                 => 587,
  :domain               => 'heroku.com',
  :user_name            => ENV['SENDGRID_USERNAME'],
  :password             => ENV['SENDGRID_PASSWORD'],
  :authentication       => :plain,
  :enable_starttls_auto => true  
}

You could substitute these for settings for another external SMTP server, or look at Mandrill for transactional emails.

I suspect the Errno::EPIPE error you were seeing was that it could not connect to a valid SMTP server, so your controller code should be fine as it is.

他のヒント

Pat is right, you don't need an add-on, just configure your app.rb like stef suggests and you're good to go. So, for example, we use gmail and our config looks something like this:

  set :delivery_method, :smtp => {
    :address              => "smtp.domain.com",
    :port                 => 587,
    :domain               => 'rails.domain.com',
    :user_name            => "rails@domain.com",
    :password             => "super-secret",
    :authentication       => "plain",
    :enable_starttls_auto => true,
    :openssl_verify_mode  => OpenSSL::SSL::VERIFY_NONE
  }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top