首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > Ruby Rails >

Net:SMTPAuthenticationError (530 5.7.0 Must issue a STARTTLS command first. 23s

2012-12-18 
Net::SMTPAuthenticationError (530 5.7.0 Must issue a STARTTLS command first. 23s在配置发送邮件设置

Net::SMTPAuthenticationError (530 5.7.0 Must issue a STARTTLS command first. 23s
在配置发送邮件设置的时候
  ActionMailer::Base.smtp_settings = {
      :address => 'smtp.gmail.com',
      :port => 587,
      :domain => 'gmail.com',
      :authentication => :plain,
      :user_name => '***帐号不带@gmail.com****', #例如abc@gmail.com 只写abc
      :password => '***密码***',
      :enable_starttls_auto => true:cram_md5
  }

Net::SMTPAuthenticationError (530 5.7.0 Must issue a STARTTLS command first. 23sm1922646pzk.0

在邮件配置的时候总是出现这种问题,后台经过学习,需要增加一个smtp-tls gem包

1、安装方法 :
sudo gem install ambethia-smtp-tls -v '1.1.2' --source http://gems.github.com

2、如果是rails 3
Gemfile要写如下:
gem 'ambethia-smtp-tls'

3、然后如下写:
require 'smtp-tls'
RailsCoders::Application.configure do
  config.action_mailer.delivery_method = :smtp
  ActionMailer::Base.smtp_settings = {
          :address => 'smtp.gmail.com',
      :port => 587,
      :domain => 'gmail.com',
      :authentication => :plain,
      :user_name => '***帐号不带@gmail.com****', #例如abc@gmail.com 只写abc
      :password => '***密码***',
      :enable_starttls_auto => true
  }

这样就可以发送了。

原文地址:http://railsforum.com/viewtopic.php?id=34622

热点排行