阿里云的主机发邮件的问题


(宋洋宇) #1

我在阿里云上的主机通过 discourse_docker 来build的,这是基本设置:

  DISCOURSE_SMTP_ADDRESS: smtpdm.aliyun.com
  DISCOURSE_SMTP_PORT: 465
  DISCOURSE_SMTP_USER_NAME: <login email>
  DISCOURSE_SMTP_PASSWORD: <login password>
  DISCOURSE_SMTP_AUTHENTICATION: login
  DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none
  DISCOURSE_SMTP_ENABLE_START_TLS: true

用这个设置启动主机发邮件,得到错误:

Processing by SessionController#csrf as */*
  Parameters: {"_"=>"1536731906118"}
Completed 200 OK in 2ms (Views: 0.3ms)
Started POST "/session/forgot_password" for 101.100.177.178 at 2018-09-12 05:58:33 +0000
Processing by SessionController#forgot_password as */*
  Parameters: {"login"=>"<my email address>"}
Completed 200 OK in 21ms (Views: 0.3ms | ActiveRecord: 5.3ms)
Sent mail to <my email address> (17496.6ms)
Job exception: end of file reached

用这个script在阿里云上测试,邮件可以顺利发送:

require 'mail'

Mail.defaults do
  delivery_method :smtp,
    :port      => 465,
    :address   => "smtpdm.aliyun.com",
    :user_name => "<login email>",
    :password  => "<login password>",
    :enable_starttls_auto => true,
    :tls => true,
    :openssl_verify_mode => 'none'
end

mail = Mail.deliver do
  to      '<我的邮件>'
  from    '<login email>'
  subject 'Hello'
  text_part do
    body 'Testing mail'
  end
end

我觉得是我的app.yml设置中漏掉了什么,但不知具体漏掉了啥。大家有什么建议么?

多谢