对于我目前的satchmo商店,我想发送html电子邮件,而不是所有的txt电子邮件。通过satchmo_store帐户注册码的外观,所有电子邮件都被硬编码并使用.txt格式而不是html格式。 例如mail.pysatchmo mail.py发送html电子邮件,而不是文本电子邮件
"""Sends mail related to accounts."""
from django.conf import settings
from django.utils.translation import ugettext
from satchmo_store.mail import send_store_mail
from satchmo_store.shop.models import Config
from satchmo_store.shop.signals import registration_sender
import logging
log = logging.getLogger('satchmo_store.accounts.mail')
# TODO add html email template
def send_welcome_email(email, first_name, last_name):
"""Send a store new account welcome mail to `email`."""
shop_config = Config.objects.get_current()
subject = ugettext("Welcome to %(shop_name)s")
c = {
'first_name': first_name,
'last_name': last_name,
'site_url': shop_config.site and shop_config.site.domain or 'localhost',
'login_url': settings.LOGIN_URL,
}
send_store_mail(subject, c, 'registration/welcome.txt', [email],
format_subject=True, sender=registration_sender)
我知道你可以改变的最后一行,以便以下,使其工作:
send_store_mail(
subject=subject,
context=c,
template='registration/welcome.txt',
recipients_list=[email],
format_subject=True,
sender=registration_sender,
template_html='registration/welcome.html')
然而,这将是在不触及代码在我的最佳利益Satchmo应用程序在不久的将来升级。
有没有人知道什么是理想的方式来覆盖此功能或启用HTML电子邮件的所有注册相关的功能,而无需触摸satchmo应用程序?
在此先感谢。
谢谢,贝壳。我设法为注册函数创建了view.py和form.py和mail.py的本地副本,并为注册函数添加了替换url,并且完美地工作。我想我只需要确保这是为稍后的升级而注意的,所以我将不得不稍后更新本地注册功能。再次感谢。 – jack