2011-09-06 54 views
0

ERS, 每當我的應用程序發送一個純文本電子郵件,通知對各種事物的人的電子郵件作爲兩個不同的電子郵件解釋或收到一些電子郵件客戶端。它適用於Gmail和comcast。通過虛擬主機隨附的通用主機獲得電子郵件的用戶將收到兩封具有相同純文本電子郵件的電子郵件。這非常煩人。我將不勝感激。直到修復我才能啓動。請賜予你強大的智慧!我喜歡這個網站!電子郵件被解釋爲兩個電子郵件

配置/初始化/爲setup_mail.rb

ActionMailer::Base.default_content_type = "text/plain" 

配置/環境/ production.rb

config.action_mailer.delivery_method = :smtp 
config.action_mailer.smtp_settings = { 
:address    => "mail.xxxessment.com", 
:port     => 26, 
:domain    => "www.xxxessment.com", 
:user_name   => "systemadmin+xxxessment.com", 
:password    => "secret", 
:authentication  => "plain", 
:enable_starttls_auto => false 
} 

型號/ actionitem_observer.rb

def after_save(actionitem) 
    if actionitem.responsible_id_changed? and !actionitem.responsible_id.nil? 
    Notifier.deliver_responsible_alert(actionitem, actionitem.responsible.email) 
    end 
    end 

郵寄/ notifier.rb

def responsible_alert(actionitem,responsible_email) 
    subject  "New action item assignment from xxxxx Assessment" 
    from   "[email protected]" 
    recipients responsible_email 
    sent_on  Time.zone.now 
    content_type "text/plain" 
    body   :actionitem => actionitem 
end 

的意見/通知/ responsible_alert.text.erb

You have been assigned Action Item #<%= @actionitem.id %> in the xxxessment system. 
Action Item: <%= @actionitem.name %> 
Please login in and look at the My Action Items tab to find the new item. 
Thank you. 

回答

0

釷eproblem這裏是一個老版本的語法。我想這不是在notifier.rb中編寫代碼的rails 3方式,它的工作原理非常好。

def responsible_alert(actionitem,responsible_email) 
    @actionitem = actionitem  
    @responsible_email = responsible_email 
    mail(:to => @responsible_email, :subject => "New action item assignment from SXXXXXssessment") do |format| 
     format.html 
     format.text 
    end  
end