Note that there are some explanatory texts on larger screens.

plurals
  1. POconnection error ActionMailer
    text
    copied!<p>I am developing a rails application using Rails 4 and Ruby 2.0.0. I have a form in my contact page from where I want to send an email to the administrator. I've chosen to work with smtp and here is my configuration file:</p> <pre><code># config/initializers/setup_mail.rb ActionMailer::Base.smtp_settings = { adress: "smtp.gmail.com", port: 587, domain: "gmail.com", user_name: "my-gmail-login@gmail.com", password: "my-gmail-password", authentication: :plain, enable_starttls_auto: true } ActionMailer::Base.default_url_options[:host] = "localhost:3000" ActionMailer::Base.raise_delivery_errors = true </code></pre> <p>Here is my mailer controller:</p> <pre><code># mailers/user_mailer.rb class UserMailer &lt; ActionMailer::Base default from: "my-gmail-login@gmail.com" def welcome_email(user) @user = user @url = "localhost:3000/signin" mail(to: user.email, subject: "Welcome") end end </code></pre> <p>And finally, my mailer view:</p> <pre><code># app/views/user_mailer/welcome_mailer.html.erb &lt;h1&gt;Congratulations "#{@user.firstname} #{@user.lastname}"&lt;/h1&gt; </code></pre> <p>When I open "$> rails console", I type the following:</p> <pre><code>$&gt; UserMailer.welcome_email(User.first).deliver </code></pre> <p>Given rails documentation <a href="http://guides.rubyonrails.org/action_mailer_basics.html" rel="nofollow">http://guides.rubyonrails.org/action_mailer_basics.html</a>, this is all I need. Unfortunately I have a connection error:</p> <pre><code>Sent mail to xxx@gmail.com (10.4ms) Date: Tue, 21 May 2013 23:09:49 +0200 From: my-gmail-login@gmail.com To: xxx@gmail.com Message-ID: &lt;519be29...-Mac.local.mail&gt; Subject: =?UTF-8?Q?Welcome?= Mime-Version: 1.0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable &lt;h1&gt;Congratulations XXX YYY&lt;/h1&gt;= Errno::ECONNREFUSED: Connection refused - connect(2) from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/net/smtp.rb:540:in `initialize' from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/net/smtp.rb:540:in `open' from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/net/smtp.rb:540:in `tcp_socket' from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/net/smtp.rb:550:in `block in do_start' from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/timeout.rb:65:in `timeout' from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/net/smtp.rb:549:in `do_start' from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/net/smtp.rb:519:in `start' from /usr/local/rvm/gems/ruby-2.0.0-rc2/gems/mail-2.5.3/lib/mail/network/delivery_methods/smtp.rb:136:in `deliver!' from /usr/local/rvm/gems/ruby-2.0.0-rc2/gems/mail-2.5.3/lib/mail/message.rb:2033:in `do_delivery' from /usr/local/rvm/gems/ruby-2.0.0-rc2/gems/mail-2.5.3/lib/mail/message.rb:229:in `block in deliver' from /usr/local/rvm/gems/ruby-2.0.0-rc2/gems/actionmailer-4.0.0.beta1/lib/action_mailer/base.rb:456:in `block in deliver_mail' from /usr/local/rvm/gems/ruby-2.0.0-rc2/gems/activesupport-4.0.0.beta1/lib/active_support/notifications.rb:158:in `block in instrument' from /usr/local/rvm/gems/ruby-2.0.0-rc2/gems/activesupport-4.0.0.beta1/lib/active_support/notifications/instrumenter.rb:20:in `instrument' from /usr/local/rvm/gems/ruby-2.0.0-rc2/gems/activesupport-4.0.0.beta1/lib/active_support/notifications.rb:158:in `instrument' from /usr/local/rvm/gems/ruby-2.0.0-rc2/gems/actionmailer-4.0.0.beta1/lib/action_mailer/base.rb:454:in `deliver_mail' from /usr/local/rvm/gems/ruby-2.0.0-rc2/gems/mail-2.5.3/lib/mail/message.rb:229:in `deliver' from (irb):1 from /usr/local/rvm/gems/ruby-2.0.0-rc2/gems/railties-4.0.0.beta1/lib/rails/commands/console.rb:88:in `start' from /usr/local/rvm/gems/ruby-2.0.0-rc2/gems/railties-4.0.0.beta1/lib/rails/commands/console.rb:9:in `start' from /usr/local/rvm/gems/ruby-2.0.0-rc2/gems/railties-4.0.0.beta1/lib/rails/commands.rb:64:in `&lt;top (required)&gt;' from bin/rails:4:in `require' from bin/rails:4:in `&lt;main&gt;'2.0.0dev :002 &gt; </code></pre> <p>Do you have any idea where this error may come from? and how to solve it?</p> <p>Thank you for your help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload