3

我查看了 Google 和 StackOverflow 并无法弄清楚这一点。

我有一个使用 Ruby 1.8.7 的 Rails 2.3.9 应用程序,尝试通过 SMTP 发送电子邮件,如下所示:

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
  :address => "smtp.sendgrid.net",
  :port => '25',
  :domain => "************.com",
  :authentication => :plain,
  :user_name => "***********",
  :password => "**********"
}

我的应用程序回溯如下所示:

/Users/jared/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/smtp.rb:551:in `initialize'
/Users/jared/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/smtp.rb:551:in `open'
/Users/jared/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/smtp.rb:551:in `do_start'
/Users/jared/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/timeout.rb:67:in `timeout'
/Users/jared/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/timeout.rb:101:in `timeout'
/Users/jared/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/smtp.rb:551:in `do_start'
/Users/jared/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/net/smtp.rb:525:in `start'
/Users/jared/.rvm/gems/ruby-1.8.7-p334/gems/actionmailer-2.3.9/lib/action_mailer/base.rb:682:in `perform_delivery_smtp'
/Users/jared/.rvm/gems/ruby-1.8.7-p334/gems/actionmailer-2.3.9/lib/action_mailer/base.rb:523:in `__send__'
/Users/jared/.rvm/gems/ruby-1.8.7-p334/gems/actionmailer-2.3.9/lib/action_mailer/base.rb:523:in `deliver!'
/Users/jared/.rvm/gems/ruby-1.8.7-p334/gems/actionmailer-2.3.9/lib/action_mailer/base.rb:429:in `deliver'
/Users/jared/rails/********/app/models/user.rb:160:in `send_welcome_email'
/Users/jared/rails/*********/app/controllers/users_controller.rb:35:in `create'
4

1 回答 1

5

我想到了。我的 ISP 阻止了 25 端口,所以我不得不更改我的配置:

ActionMailer::Base.smtp_settings = {
  :address => "smtp.sendgrid.net",
  :port => '587',
  :domain => "**********.com",
  :authentication => :plain,
  :user_name => "************",
  :password => "*********",
  :enable_starttls_auto => true
}
于 2011-03-07T19:18:41.510 回答