Skip to content

Commit 76dbd45

Browse files
authored
Merge pull request readthedocs#3355 from rtfd/more-mail-changes
Email sending: Allow kwargs for other options
2 parents bdd93a7 + 86994bc commit 76dbd45

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

readthedocs/core/tasks.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818

1919
@app.task(queue='web', time_limit=EMAIL_TIME_LIMIT)
20-
def send_email_task(recipient, subject, template, template_html, context=None, from_email=None):
20+
def send_email_task(recipient, subject, template, template_html,
21+
context=None, from_email=None, **kwargs):
2122
"""Send multipart email
2223
2324
recipient
@@ -34,12 +35,16 @@ def send_email_task(recipient, subject, template, template_html, context=None, f
3435
3536
context
3637
A dictionary to pass into the template calls
38+
39+
kwargs
40+
Additional options to the EmailMultiAlternatives option.
3741
"""
3842
msg = EmailMultiAlternatives(
3943
subject,
4044
get_template(template).render(context),
4145
from_email or settings.DEFAULT_FROM_EMAIL,
42-
[recipient]
46+
[recipient],
47+
**kwargs
4348
)
4449
try:
4550
msg.attach_alternative(get_template(template_html).render(context),

readthedocs/core/utils/__init__.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def trigger_build(project, version=None, record=True, force=False, basic=False):
134134

135135

136136
def send_email(recipient, subject, template, template_html, context=None,
137-
request=None, from_email=None): # pylint: disable=unused-argument
137+
request=None, from_email=None, **kwargs): # pylint: disable=unused-argument
138138
"""Alter context passed in and call email send task
139139
140140
.. seealso::
@@ -147,7 +147,8 @@ def send_email(recipient, subject, template, template_html, context=None,
147147
context['uri'] = '{scheme}://{host}'.format(
148148
scheme='https', host=settings.PRODUCTION_DOMAIN)
149149
send_email_task.delay(recipient=recipient, subject=subject, template=template,
150-
template_html=template_html, context=context, from_email=from_email)
150+
template_html=template_html, context=context, from_email=from_email,
151+
**kwargs)
151152

152153

153154
def slugify(value, *args, **kwargs):

0 commit comments

Comments
 (0)