Net :: OpenTimeout:尝试从Rails应用程序发送电子邮件时,执行已过期

时间:2018-11-30 12:42:20

标签: ruby-on-rails-5 actionmailer

我已经创建了一个应用程序,并设置了所有smtp配置以使用操作邮件发送电子邮件。在这里,我通过 Sendgrid 发送电子邮件。

这是我的smtp设置

ActionMailer::Base.smtp_settings = {
    :user_name => '*****',
    :password => '*****',
    :domain => 'sample.com',
    :address => 'smtp.sendgrid.net',
    :port => 587,
    :authentication => :plain,
    :enable_starttls_auto => true
  }

应用程序邮件程序

class StatusMailer < ApplicationMailer

    default from: 'testmail@gmail.com'

  def server_status_email
    @url  = 'http://example.com/login'
    mail(to: "toemail@gmail.com", subject: 'Welcome to My Awesome Site')
  end

end

但是当我尝试从控制台发送邮件时。邮件处理了出站邮件,但未送达。

Net::OpenTimeout: execution expired



2.3.1 :001 > StatusMailer.server_status_email.deliver
  Rendering status_mailer/server_status_email.html.erb within layouts/mailer
  Rendered status_mailer/server_status_email.html.erb within layouts/mailer (1.2ms)
StatusMailer#server_status_email: processed outbound mail in 179.6ms
Sent mail to testmail@gmail.com (30005.9ms)
Date: Fri, 30 Nov 2018 17:37:31 +0530
From: testmail@gmail.com
To: testmail@gmail.com
Message-ID: <5c0128031cf_34d12ac4203b90d425748@rsubuntu-OptiPlex-3040.mail>
Subject: Welcome to My Awesome Site
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style>
      /* Email styles need to be inline */
    </style>
  </head>

  <body>
    <!DOCTYPE html>
<html>
  <head>
    <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
  </head>
  <body>
    <h1>Welcome to example.com, Sethu</h1>
    <p>
      You have successfully signed up to example.com,
      your username is: Sethu<br>
    </p>
    <p>
      To login to the site, just follow this link: http://example.com/login.
    </p>
    <p>Thanks for joining and have a great day!</p>
  </body>
</html>
  </body>
</html>

Net::OpenTimeout: execution expired
    from (irb):1

我已禁用防火墙并进行了测试,但仍然没有收到邮件。

0 个答案:

没有答案