2011-04-13 71 views
0

我正在嘗試創建一個電子郵件地址。我已將sendgrid插件添加到我的應用程序中。Heroku actionmailer如何

這裏是我的application.rb中

module Konkurranceportalen 
    class Application < Rails::Application 
    # Settings in config/environments/* take precedence over those specified here. 
    # Application configuration should go into files in config/initializers 
    # all .rb files in that directory are automatically loaded. 
    config.action_mailer.delivery_method = :smtp 
    ActionMailer::Base.smtp_settings = { 
    :address => "smtp.mydomain.com", 
    :port => 25, 
    :user_name => "[email protected]", 
    :password => "mypass", 
    :authentication => :login 
} 
end 
end 
+0

問題是什麼?你沒有工作嗎?你有錯誤嗎? – 2011-04-13 08:18:36

+0

當我嘗試在thunderbird上登錄併發送郵件到[email protected]時出現錯誤 – 2011-04-13 08:20:26

+0

我應該使用sendgrids SMTP服務器還是使用Rails構建? – 2011-04-13 08:23:45

回答

0

要創建像[email protected]你需要一個郵件Exhange主機的常規電子郵件。

當你choicen郵件exhange主機,你可以創建一個像[email protected]

現在你需要設置MX記錄你的DNS服務器

而且足底對你有一個像郵件發送一個電子郵件郵件@ yourdomain.com

0

這並不像你需要使用SendGrid與在Heroku編碼 - 文檔有你需要的所有細節,here

+0

如何創建電子郵件地址,例如[email protected] – 2011-04-13 09:32:29

+0

指定在您的動作郵件程序中,請參閱http://edgeguides.rubyonrails.org /action_mailer_basics.html – 2011-04-13 10:59:53

+0

澄清,該代碼段是通過SMTP將您的應用程序連接到SendGrid所需的設置。然後您需要使用actionmailer發送您的電子郵件。 – 2011-04-13 11:42:29

1

您需要更改Sendgrid設置:

ActionMailer::Base.smtp_settings = { 
    :address  => "smtp.sendgrid.net", 
    :port   => "25", 
    :authentication => :plain, 
    :user_name  => ENV['SENDGRID_USERNAME'], 
    :password  => ENV['SENDGRID_PASSWORD'], 
    :domain   => ENV['SENDGRID_DOMAIN'] 
+0

我是否需要創建一個sendgrid帳戶? – 2011-04-13 09:09:32

+0

如何創建電子郵件地址,例如[email protected] – 2011-04-13 09:32:04

+0

不,從Heroku您不需要。你只需要將Sendgrid添加到你的應用程序中:'heroku addons:add sendgrid:free' – 2011-04-13 09:44:55