2011-04-03 181 views
6

我寫了一個自定義郵件程序,每當用戶收到通知時都會發送一封電子郵件。 由於某些原因自定義郵件工程,但內置的設計郵件不起作用。 我無法發送確認電子郵件配置設計發送電子郵件

在我的配置中缺少某些東西嗎?

-devise.rb:

config.mailer_sender = "[email protected]" 

-setup_mail.rb:

require "development_mail_interceptor" 

ActionMailer::Base.smtp_settings = { 
    :address    => "smtp.gmail.com", 
    :port     => 587, 
    :domain    => "gmail.com", 
    :user_name   => "usename", 
    :password    => "pass", 
    :authentication  => "plain", 
    :enable_starttls_auto => true 
} 



ActionMailer::Base.perform_deliveries = true 
ActionMailer::Base.raise_delivery_errors = true 
ActionMailer::Base.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development? 
+0

什麼錯誤/異常你好嗎? – 2011-04-03 07:33:10

+0

沒有,開發日誌寫道,電子郵件已發送,但我從來沒有收到它 – Gady 2011-04-03 08:41:08

+0

它最終在哪裏?系統是否通過網絡與'smtp.gmail.com'交談?你能否以某種方式增加錯誤記錄級別? – 2011-04-03 08:43:06

回答

4

我認爲,尋找到

配置/初始化/ devise.rb

會做t他欺騙了你:

config.mailer = 「制定::梅勒」

你可以取消它!

1
This can be helpful. After r&D, the final complete text is below: 

# ActionMailer Config in development/production rb file 
    config.action_mailer.default_url_options = { :host => 'localhost:3000' } 
    config.action_mailer.delivery_method = :smtp 
    # change to true to allow email to be sent during development 
    config.action_mailer.perform_deliveries = true 
    config.action_mailer.raise_delivery_errors = true 
    config.action_mailer.default :charset => "utf-8" 

    config.action_mailer.smtp_settings = { 
    address: "smtp.gmail.com", 
    port: 587, 
    domain: "mail.google.com",####important 
    authentication: "plain", 
    enable_starttls_auto: true, 
    user_name: ENV["GMAIL_USERNAME"], 
    password: ENV["GMAIL_PASSWORD"] 
    } 
0

我今天遇到問題,我花了5個小時。 當confirmation_token關係列爲空時,Devise的確認電子郵件無法工作。那麼,當列是空的,它運作良好。

#this works well 
add_column :users, :confirmation_token, :string 
add_column :users, :confirmed_at, :datetime 
add_column :users, :confirmation_sent_at, :datetime 
add_column :users, :unconfirmed_email, :string 

#But this cannot work !!! 
add_column :users, :confirmation_token, :string, :null => false, :default => '' 
add_column :users, :confirmed_at, :datetime, :null => false, :default => '1970-01-01' 
add_column :users, :confirmation_sent_at, :datetime, :null => false, :default => '1970-01-01' 
add_column :users, :unconfirmed_email, :string, :null => false, :default => '' 

希望幫助都抓住這個問題當U。〜

相關問題