2017-04-26 112 views
0

在我的應用程序中,我嘗試發送電子郵件但無法發送。在後端它顯示郵件正在發送,但在我的收件箱郵件不會來。 下面是我production.rb文件 -無法在Ruby on Rails中發送電子郵件

# require 'tls_smtp' 
Rails.application.configure do 

    config.cache_classes = false 

    config.eager_load = false 
    config.consider_all_requests_local  = false 
    config.action_controller.perform_caching = false 

    config.action_mailer.raise_delivery_errors = false 

    config.active_support.deprecation = :log 

    config.active_record.migration_error = :page_load 

    config.assets.debug = true 

    config.assets.digest = true 

    config.assets.raise_runtime_errors = true 

    config.action_mailer.perform_deliveries = true 

    config.action_mailer.default_url_options = { host: 'mail.abc.co.in', port: 3000 } 

    ActionMailer::Base.smtp_settings = { 
    :address => "mail.abc.co.in", 
    :port => 25, 
    :user_name => "[email protected]", 
    :password => "***", 
    :authentication => 'plain', 
} 

回答

0

下面是在配置/環境/ production.rb SMTP設置代碼:

config.action_mailer.default_url_options = { :host => 'http://abc.co.in' } 

config.action_mailer.smtp_settings = { 
    :address => "mail.abc.co.in", 
    :port => 587, 
    :domain => "abc.co.in", 
    :user_name => "[email protected]", 
    :password => "*********", 
    :authentication => "plain", 
    :enable_starttls_auto => true 
    } 

對於Gmail:

config.action_mailer.delivery_method = :smtp 

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

其仍無法正常工作。請幫助我。 –

+0

你有沒有設置你的郵件服務器? – puneet18

+0

make config.action_mailer.raise_delivery_errors = true並檢查錯誤日誌 – puneet18

相關問題