2010-03-23 80 views
0

我在我的應用程序中有郵件程序,郵件程序配置爲使用Gmail郵件。以下是我的配置細節下的environment.rb文件自定義Rails應用程序中的發件人地址

require "smtp_tls" 
ActionMailer::Base.delivery_method = :smtp 
ActionMailer::Base.perform_deliveries = true 
ActionMailer::Base.raise_delivery_errors = true 
ActionMailer::Base.default_charset = "utf-8" 
ActionMailer::Base.default_content_type = "text/html" 

ActionMailer::Base.smtp_settings = { 
:address => "smtp.gmail.com", 
:port => 587, 
:domain => 'gmail.com', 
:user_name => "[email protected]", 
:password => "password", 
:authentication => :plain 

的認爲我要實現的,當過應用產生電子郵件發件人地址顯示爲「[email protected]」。

是否可以自定義發件人地址。在不同的地方,我想用不同的發件人地址,而不是「[email protected]

我與我的郵件模式的嘗試:

@from = "#{user.email}" 

在開發服務器記錄它正確地顯示定製的ID。如果去我的電子郵件收件箱,它顯示的地址爲「[email protected]

任何人都可以請指導。提前致謝。

回答

1

這不是@from。這是方法from

def my_email_sender_method 

    from "nobody <[email protected]>" 
end 
+0

嗨,感謝您的信賴。是否可以將<[email protected]>更改爲<#{user.email}>。在那個地方 – palani 2010-03-23 13:06:18

+0

當然。你可以設置任何你想要的簡單字符串或變量。 – 2010-03-23 13:43:28