Rails应用程序使用DigitalOcean上的Ubuntu向SendGrid发送联系电子邮件

时间:2016-02-23 20:33:29

标签: ruby-on-rails smtp ubuntu-14.04 sendgrid

当有人填写表单时,尝试将消息发送到地址。但是我收到了错误:

Errno::ECONNREFUSED in SupportrequestsController#create
Connection refused - connect(2) for "smtp.sendgrid.net" port 587

@supportrequest = Supportrequest.new(params[:supportrequest])

     if @supportrequest.save  <---GETTING ERROR HERE
        HydraNotifier.send_support_email(@supportrequest).deliver
        flash.now[:error] = nil
        redirect_to( contact_path, :notice => 'email sent')

我正在使用:
Rails 4.2.5.1
红宝石2.2.3p173

的Gemfile:

gem&#39; mail_form&#39;,&#39;〜&gt; 1.5&#39;,&#39;&gt; = 1.5.1&#39;
gem&#39; sendgrid&#39;

以下是我的SMTP设置:

config.action_mailer.delivery_method = :smtp  
ActionMailer::Base.smtp_settings = {
    :address => "smtp.sendgrid.net",
    :port => 587,
    :user_name => ENV['SENDGRID_USER'],
    :password => ENV['SENDGRID_PASS'],
    :domain => "mydomain.com",
    :authentication => :plain,
    :enable_starttls_auto => true
  }

0 个答案:

没有答案