所以我在Digital Ocean上有这个项目,它确实有一个ipv6。根据Rails指南,我还设置了我的Gmail帐户,以接受安全性较低的应用,以避免两步验证,因为它只是发送给员工的电子邮件。发生更新操作时,我一直试图收到电子邮件,但收到错误消息。不确定我可以采取哪些步骤来解决此问题
错误记录
I, [2017-12-28T01:21:53.559309 #30437] INFO -- : [99d7e265-eb0a-4bd4-a535-6faab87db03e] Completed 500 Internal Server Error in 30346ms (ActiveRecord: 33.9ms)
F, [2017-12-28T01:21:53.561006 #30437] FATAL -- : [99d7e265-eb0a-4bd4-a535-6faab87db03e]
F, [2017-12-28T01:21:53.561079 #30437] FATAL -- : [99d7e265-eb0a-4bd4-a535-6faab87db03e] Net::OpenTimeout (execution expired):
F, [2017-12-28T01:21:53.561132 #30437] FATAL -- : [99d7e265-eb0a-4bd4-a535-6faab87db03e]
F, [2017-12-28T01:21:53.561177 #30437] FATAL -- : [99d7e265-eb0a-4bd4-a535-6faab87db03e] app/models/listing.rb:55:in `listing_update_notification'
[99d7e265-eb0a-4bd4-a535-6faab87db03e] app/controllers/listings_controller.rb:53:in `block in update'
[99d7e265-eb0a-4bd4-a535-6faab87db03e] app/controllers/listings_controller.rb:47:in `update'
控制器
...
def update
@listing = Listing.find(params[:id])
@listing.attributes = listing_params
respond_to do |format|
if @listing.save
format.html { redirect_to [building, @listing], notice: 'Listing was successfully updated.' }
format.json { render :show, status: :ok, location: @listing }
ListingMailer.listing_email(@listing).deliver_now
elsif params[:listing][:active] == "0" || Listing.find(params[:id]).active ==true
@listing.save(validate: false)
format.html { redirect_to [building, @listing], notice: 'Listing was successfully updated.' }
format.json { render :show, status: :ok, location: @listing }
ListingMailer.listing_email(@listing).deliver_now
else
format.html { render :edit }
format.json { render json: @listing.errors, status: :unprocessable_entity }
end
end
end
production.rb
...
# SMTP Settings for Sending Email
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'example.com',
user_name: ENV['GMAIL_USER'],
password: ENV['GMAIL_PW'],
authentication: 'plain',
enable_starttls_auto: true }
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
listing.rb - 添加了缺失的模型和方法
class Listing < ApplicationRecord
...
include ActiveModel::Dirty
after_update :listing_update_notification
...
private
...
def listing_update_notification
ListingMailer.listing_email(self, self.changes).deliver
end
end
更新:我添加了缺少的模型,并且还从控制器更新操作中删除了ListingMailer,但是在生产日志中收到了相同的错误消息
更新#2 :我还与DigitalOcean进行了交谈,并将服务器更改为优先使用IPv4并仍然遇到相同的错误