2013-07-29 41 views
0

我正在Linode上部署Rails應用程序。無法接收來自linode rails的電子郵件應用程序

這裏有點奇怪。我爲電子郵件設置了Gmail(例如,歡迎電子郵件)。如果我使用我的個人電子郵件註冊,我可以正確接收電子郵件。但是,如果我使用我公司的電子郵件進行註冊,我無法收到(即使在垃圾郵件中)。

我檢查了gmail帳戶(發送電子郵件)。事實證明,Gmail已正確發送所有電子郵件(我可以在發送郵件中看到所有電子郵件)。

然後我嘗試了一下本地機器的開發環境。我公司的電子郵件帳戶可以收到歡迎電子郵件。

它在我看來,1.促銷模式下的電子郵件設置是可以的。至少我的個人帳戶,例如Gmail,Hotmail可以收到歡迎郵件。 2.我公司的電子郵件服務器允許傳入的Gmail,因爲它在開發模式下工作。

不太確定爲什麼我公司的帳戶無法從linode上的生產模式下的Rails應用程序接收電子郵件。是否因爲電子郵件是從linode發送的,以便我公司的電子郵件服務器忽略來自這些IP地址的電子郵件?我以爲電子郵件是由gmail sever而不是linode發送的,理解是否正確?有沒有人可能會給我一些線索?

貼我production.rb

# Send deprecation notices to registered listeners 
config.active_support.deprecation = :notify 
config.action_mailer.default_url_options = { :host => 'xxxxx.com' } 
#config.action_mailer.delivery_method = :smtp 
config.action_mailer.raise_delivery_errors = false 
config.action_mailer.perform_deliveries = true 
#config.action_mailer.default :charset => "utf-8" 

和environment.rb中

ActionMailer::Base.delivery_method = :smtp 
ActionMailer::Base.smtp_settings = 
{ 
    :address => "smtp.gmail.com", 
    :port => 587, 
    :domain => "xxxxx.com", 
    :user_name => "[email protected]", 
    :password => "xxxxxx", 
    :authentication => :plain, 
    :enable_starttls_auto => true 
} 
+0

你在你的config.rb文件中設置了域嗎? –

回答

0

您是否設置環境變量?例如在你的環境/ production.rb中應該有這樣的東西。

config.action_mailer.default_url_options = {:主機=> 「yourhost」}

+0

是的,這是在我的production.rb – user1495133

0

一次嘗試開發機器上啓動生產模式的應用程序,並在production.rb設置

config.action_mailer.raise_delivery_errors = true

然後再次嘗試發送電子郵件。

+0

我認爲問題不是電子郵件沒有發出,但我公司的電子郵件帳戶無法接收。我嘗試將riase_delivery_errors更改爲true,但不幸的是它沒有工作。 – user1495133

0

我知道這個問題是一對夫婦歲,但我想我會張貼我工作。以下是我用來從Gmail中發送電子郵件託管在我的Linode服務器上我的Rails應用程序:

config/environments/production.rb

我錯過這裏是協議,設置的第一部分,爲http

config.action_mailer.default_url_options = { host: 'HOST_NAME', protocol: 'http' }

下一步,仍然在config/environments/production.rb

config.action_mailer.default :charset => "utf-8"

最後一點,仍然在config/environments/production.rb

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

如果,這些變化之後,它仍然不能正常工作,請嘗試更改config/initializers/devise.rb如下:

config.mailer_sender = '[email protected]'

確保郵件給在config/initializers/devise.rbconfig/environments/production.rb中給出的匹配。

希望這可以幫助別人。

相關問題