2011-04-06 61 views
1

我已經被客戶請求,他的satchmo商店應該在重置他的密碼時發送html格式的郵件。satchmo password_reset html格式郵件

Aparently satchmo或django的contrib.auth.views.password_reset只發送原始郵件。

如何修改此以便能夠發送html格式的郵件?

謝謝!

回答

5

我還沒有使用Satchmo,但這應該讓你開始。

首先,子類PasswordResetForm,並覆蓋save方法發送一個HTML電子郵件,而不是一個純文本電子郵件。您可以使用existing PasswordResetForm作爲指導。您需要將末尾的send_mail調用替換爲發送HTML電子郵件的代碼。有關sending html emails的文檔應該有所幫助。

一旦你寫完你的表格,你需要在password_reset的url模式中包含表格。正如我所說的,我沒有Satchmo的任何經驗,但是看看源代碼,我想你想更新satchmo_store.accounts.urls,通過更改password_reset_dict。

# You need to import your form, or define it in this module 
from myapp.forms import HTMLPasswordResetForm 

#Dictionary for authentication views 
password_reset_dict = { 
    'template_name': 'registration/password_reset_form.html', 
    # You might want the change the email template to .html 
    'email_template_name': 'registration/password_reset.txt', 
    'password_reset_form': HTMLPasswordResetForm, 
} 

# the "from email" in password reset is problematic... it is hard coded as None 
urlpatterns += patterns('django.contrib.auth.views', 
    (r'^password_reset/$', 'password_reset', password_reset_dict, 'auth_password_reset'), 
    ...