到目前爲止,我只找到能夠在Rails 3中工作的解決方案。我如何強制將使用ActionMailer發送的電子郵件格式化爲HTML,而不是純文本格式?如何在Rails 2.3.11中以HTML格式發送郵件?
/app/models/franklin.rb(郵包)
class Franklin < ActionMailer::Base
def activation(user)
recipients user.email
from "[email protected]"
content_type = "text/html"
subject "OnCampus @ RIT Registration"
body :user => user
end
end
/app/views/franklin/activation.html.erb
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
Hi <%= @user.full_name %>,
This is your activation email for OnCampus @ RIT. All you have to do is click the link below, and you'll be able to log in.
<%= link_to "Activate My Account!", "http://rit.oncampusapp.net/admin/activate?key=#{@user.activation_key}"%>
We hope to see you soon! :D
-- The OnCampus Team
</body>
</html>
我在Rails的相當新的,所以我不太明白你的意思。你能否詳細說明一下? – Benjin
在你發佈的問題** content_type =「text/html」**這是一個錯字? – naren