2011-08-07 74 views
0

我有以下設置在標誌發送電子郵件了起來:Ruby on Rails的3:發送電子郵件幫助

的Rails 3.0.7

紅寶石1.9.2p180(2011-02-18修訂30909) x86_64的Linux的]

Rails插件安裝的git://github.com/collectiveidea/action_mailer_optional_tls.git

梅勒

class UserMailer < ActionMailer::Base 

    def registration_confirmation(user) 
    recipients user.email 
    from  "[email protected]" 
    subject  "Thank you for Registering" 
    body  :user => user 
    end 
end 

控制器:

def create 
    @user = User.new(params[:user]) 
    if @user.save 
     UserMailer.deliver_registration_confirmation(@user) 
     sign_in @user 
     flash[:success] = "Welcome to ECE" 
     redirect_to @user 
    else 
     @title = "Sign up" 
     render 'new' 
    end 
    end 

查看:

Hi <%= @user.name %>, ..... 

我得到的SMTP連接錯誤,我谷歌搜索後,這包括在Gemfile中。

這解決了錯誤

的Gemfile

gem 'rack-ssl', :require => 'rack/ssl' 

配置/環境/ development.rb

config.action_mailer.raise_delivery_errors = true 
    config.action_mailer.delivery_method = :smtp 
    config.middleware.insert_before ActionDispatch::Static, "Rack::SSL" 
    config.action_mailer.smtp_settings = { 
    :enable_starttls_auto => true, 
    :address  => 'smtp.gmail.com', 
    :authentication => :login, 
    :port   => 587, 
    :domain   => 'www.example.com', 
    :name   => '[email protected]', 
    :password  => 'password', 
    } 

問題

早期的版本我WA獲得535-5.7.1用戶名和密碼不被接受。

現在它說:

SSL連接錯誤

無法建立到服務器的安全連接。這可能是服務器的問題,或者它可能需要您沒有的客戶端身份驗證證書。

錯誤107(net :: ERR_SSL_PROTOCOL_ERROR):SSL協議錯誤。

有什麼建議嗎?

回答

1
我一直在使用Gmail發送電子郵件,並沒有配置任何額外的寶石

。這就是我在development.rb中所做的。

config.action_mailer.smtp_settings = { 
    :tls => true, 
    :enable_starttls_auto => true, 
    :address => "smtp.gmail.com", 
    :port => "587", 
    :domain => "domain.com", 
    :authentication => :plain, 
    :user_name => "[email protected]", 
    :password => "password" 
} 

要注意的要點是:

注:該值:域名是谷歌Apps網域。如果您使用屬於gmail.com的用戶名,我認爲它不是必需的。

1

導軌指南有一個gmail示例。他們的身份驗證設置爲普通。也許給它一個鏡頭?

config.action_mailer.delivery_method = :smtp 
config.action_mailer.smtp_settings = { 
  :address              => "smtp.gmail.com", 
  :port                 => 587, 
  :domain               => 'baci.lindsaar.net', 
  :user_name            => '<username>', 
  :password             => '<password>', 
  :authentication       => 'plain', 
  :enable_starttls_auto => true  } 

http://edgeguides.rubyonrails.org/action_mailer_basics.html

+0

我得到同樣的錯誤。昨晚我沒有得到這個錯誤。 – Wasi

+0

也許嘗試:openssl_verify_mode =>'無'?你的SSL堆棧中的東西似乎有問題。 –

+0

也嘗試過。 – Wasi

相關問題