无法使用来自服务器的动作邮件发送电子邮件

时间:2013-11-19 14:07:31

标签: ruby-on-rails actionmailer

只是不明白。我的环境文件的所有三个(绝望)都是相同的,看起来像这样:那是environment.rb,test.rb和development.rb

Drivetastic::Application.configure do
  config.action_mailer.default_url_options = { host: "gmail.com" }
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com",
    port: 587,
    domain: "gmail.com",
    authentication: :plain,
    enable_starttls_auto: true,
    user_name: "me@gmail.com",
    password: "secret"
  }

#  config.action_mailer.async = true
  ###

  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports and disable caching.
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send.
#  config.action_mailer.raise_delivery_errors = false

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations
  config.active_record.migration_error = :page_load

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = true
end

当我通过action_mailer发送电子邮件时,它会完美地发送电子邮件!当我将应用程序上传到服务器并执行相同的操作时,我得到了这个:

Net::SMTPAuthenticationError in MessagesController#create
534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbvCQ

这是我的日志:

Started POST "/messages" for 2.12.109.89 at 2013-11-19 08:54:37 -0500
Processing by MessagesController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"6Fr5xsg8Gn/mjc8Pxtl6wdfV/wfJAybNjAKgMIB0t+g=", "message"=>{"name"=>"12345", "town"=>"abcdef", "email"=>"iiiiiiix", "content"=>"yep"}, "commit"=>"$
  Rendered contactform/contact.html.erb (0.1ms)
  Rendered contactform/contact.text.erb (0.0ms)

Sent mail to me@gmail.com (12.6ms)
Date: Tue, 19 Nov 2013 08:54:37 -0500
From: me@gmail.com
To: me@gmail.com
Message-ID: <528b6d9dcd60c_73792a055e4422e6@HAL9000.mail>
Subject: 12345 is trying to reach you! (from Drivetastic.com)
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="--==_mimepart_528b6d9dcbaef_73792a055e442183";
 charset=UTF-8
Content-Transfer-Encoding: 7bit


----==_mimepart_528b6d9dcbaef_73792a055e442183
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

ContactForm#contact

Email from potential student!

, find me in app/views/app/views/contact_form/contact.text.erb

----==_mimepart_528b6d9dcbaef_73792a055e442183
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://w=
ww.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=3D"http://www.w3.org/1999/xhtml">

<html>
<body>
Note: This is an automated message! No one will read any replies you send=
 to it! To reach the contact, email . If you have any problems, email Jul=
ian at. </body>
</html>

----==_mimepart_528b6d9dcbaef_73792a055e442183--

Completed 500 Internal Server Error in 33ms

Errno::ECONNREFUSED (Connection refused - connect(2)):
  app/controllers/messages_controller.rb:17:in `create'

日志帮助不大。太烦人了,不知道为什么会这样。相同的项目在本地工作,环境相同。

我可以很好地登录和退出gmail ...没有重新收集的东西,没有。

**更新**

好的,所以我认为这是我的vps的一个问题。它正在运行Ubuntu。这个区域有点菜鸟,但是你可以建议做什么吗?我应该配置防火墙吗?打开一个港口?我该怎么办?

至于这个被封闭的问题,我认为Ubuntu + Nginx + Rails被广泛使用。

0 个答案:

没有答案