When I connect to the production environment through my git, my SMTP works, but when I connect through heroku it doesn't
当我通过我的git连接到生产环境时,我的SMTP可以工作,但是当我通过heroku连接时,它没有
I'm trying to make an app which everytime someone'd make a comment, an email would be sent.
我正在尝试创建一个每次有人发表评论的应用程序,都会发送一封电子邮件。
When I connect through "rails s --environment=production" in git, everything works as expected, but when I deploy my app to heroku, I get an 500 "(Internal Server Error)" in my chrome console and nothing is sent.
当我通过git中的“rails s --environment = production”连接时,一切都按预期工作,但是当我将我的应用程序部署到heroku时,我的chrome控制台中出现了500“(内部服务器错误)”并且没有发送任何内容。
-These are my production action_mailer configurations:
- 这些是我的生产action_mailer配置:
config.action_mailer.default_url_options = { host: "warm-mesa-2622.herokuapp.com" }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
:address => "smtp.interativasistemas.com",
:port => 587,
:domain => 'warm-mesa-2622.herokuapp.com',
:user_name => 'my_user@interativasistemas.com',
:password => <password>,
:authentication => 'login',
:enable_starttls_auto => true,
:enable_ssl => true,
:openssl_verify_mode => 'none'
}
-This is the log from my git connection of when I create a new comment, which everything goes as expected:
- 这是我创建新评论时我的git连接的日志,一切都按预期进行:
Started POST "/jobs/15/comments" for 127.0.0.1 at 2014-08-22 15:33:19 -0300
Processing by CommentsController#create as JS
Parameters: {"utf8"=>"✓", "authenticity_token"=>"r4fDJrBWRjKgNqwMlfqRAzMZO8fPC
vjaPOxVfAghGb0=", "comment"=>{"name"=>"Comment", "body"=>"Comment Post."}, "comm
it"=>"Send", "job_id"=>"15"}
Rendered company_mailer/new_comment.html.erb (1.0ms)
Rendered company_mailer/new_comment.text.erb (1.0ms)
Sent mail to mella.neto@gmail.com (1514ms)
Rendered comments/_comment.html.erb (15.0ms)
Rendered comments/create.js.erb (20.0ms)
Completed 200 OK in 5192ms (Views: 31.0ms | ActiveRecord: 3509.2ms)
cache: [POST /jobs/15/comments] invalidate, pass
-This is the same log on my heroku connection which everything goes wrong, and the email isn't sent:
- 这是我的heroku连接上的相同日志,一切都出错了,电子邮件没有发送:
←[36m2014-08-22T18:37:22.843252+00:00 app[web.1]:←[0m Started POST "/jobs/15/com
ments" for 187.23.176.51 at 2014-08-22 18:37:22 +0000
←[36m2014-08-22T18:37:22.845655+00:00 app[web.1]:←[0m Processing by CommentsCont
roller#create as JS
←[36m2014-08-22T18:37:22.845725+00:00 app[web.1]:←[0m Parameters: {"utf8"=>"��
�", "authenticity_token"=>"e07XWzBXlkYBLVXIhGMCxVhekzMpayaGXrUoTH2Xgco=", "comme
nt"=>{"name"=>"Comment", "body"=>"Comment Body."}, "commit"=>"Send", "job_id"=>"
15"}
←[36m2014-08-22T18:37:22.866964+00:00 app[web.1]:←[0m Rendered company_mailer/
new_comment.html.erb (0.6ms)
←[36m2014-08-22T18:37:22.867544+00:00 app[web.1]:←[0m Rendered company_mailer/
new_comment.text.erb (0.3ms)
←[33m2014-08-22T18:37:23.213749+00:00 heroku[router]:←[0m at=info method=POST pa
th="/jobs/15/comments" host=warm-mesa-2622.herokuapp.com request_id=15dba4d8-7b2
7-4cf0-9da8-ea0b117201c0 fwd="187.23.176.51" dyno=web.1 connect=1ms service=373m
s status=500 bytes=1274
←[36m2014-08-22T18:37:23.203501+00:00 app[web.1]:←[0m
←[36m2014-08-22T18:37:23.203508+00:00 app[web.1]:←[0m Sent mail to mella.neto@gm
ail.com (327ms)
←[36m2014-08-22T18:37:23.203846+00:00 app[web.1]:←[0m Completed 500 Internal Ser
ver Error in 358ms
←[36m2014-08-22T18:37:23.205470+00:00 app[web.1]:←[0m
←[36m2014-08-22T18:37:23.205473+00:00 app[web.1]:←[0m Errno::ECONNREFUSED (Conne
ction refused - connect(2)):
←[36m2014-08-22T18:37:23.205475+00:00 app[web.1]:←[0m app/controllers/comments
_controller.rb:7:in `create'
←[36m2014-08-22T18:37:23.205476+00:00 app[web.1]:←[0m
←[36m2014-08-22T18:37:23.205478+00:00 app[web.1]:←[0m
←[36m2014-08-22T18:37:23.205798+00:00 app[web.1]:←[0m cache: [POST /jobs/15/comm
ents] invalidate, pass
This is my my comments_controller create function:
这是我的comments_controller创建函数:
def create
@job = Job.find(params[:job_id])
@comment = @job.comments.build(params[:comment])
if success = @comment.save
CompanyMailer.new_comment(@job, @comment).deliver
end
respond_to do |format|
format.html do
if success
flash[:notice] = "Comment was created with success!"
else
flash[:alert] = "Comment could not be created!"
end
redirect_to @job
end
format.js
end
end
And also my company_mailer which defines the email function:
还有我的company_mailer定义了电子邮件功能:
class CompanyMailer < ActionMailer::Base
default from: "my_user@interativasistemas.com"
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.company_mailer.new_comment.subject
#
def new_comment(job, comment)
@job = job
@comment = comment
@company = job.company
mail to: @company.email, subject: "New comment received"
end
end
Can anyone help me please ? I'm using ruby 1.9.3 and rails 3.2.2
有人可以帮我吗?我正在使用ruby 1.9.3和rails 3.2.2
1 个解决方案
#1
0
To debug problems like this, you want to create a one-off dyno with heroku run bash
and then rails s
or rails console
from there.
为了这样的调试问题,你想创建一个一次性的赛道与Heroku的运行bash和轨道,然后S或从那里轨道控制台。
#1
0
To debug problems like this, you want to create a one-off dyno with heroku run bash
and then rails s
or rails console
from there.
为了这样的调试问题,你想创建一个一次性的赛道与Heroku的运行bash和轨道,然后S或从那里轨道控制台。