Skip to content

Commit bdd93a7

Browse files
authored
Merge pull request readthedocs#3349 from rtfd/better-email
Small changes to email sending to enable from email
2 parents 8db7198 + c6e21ad commit bdd93a7

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

readthedocs/core/tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
@app.task(queue='web', time_limit=EMAIL_TIME_LIMIT)
20-
def send_email_task(recipient, subject, template, template_html, context=None):
20+
def send_email_task(recipient, subject, template, template_html, context=None, from_email=None):
2121
"""Send multipart email
2222
2323
recipient
@@ -38,7 +38,7 @@ def send_email_task(recipient, subject, template, template_html, context=None):
3838
msg = EmailMultiAlternatives(
3939
subject,
4040
get_template(template).render(context),
41-
settings.DEFAULT_FROM_EMAIL,
41+
from_email or settings.DEFAULT_FROM_EMAIL,
4242
[recipient]
4343
)
4444
try:

readthedocs/core/utils/__init__.py

Lines changed: 3 additions & 2 deletions
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): # pylint: disable=unused-argument
137+
request=None, from_email=None): # pylint: disable=unused-argument
138138
"""Alter context passed in and call email send task
139139
140140
.. seealso::
@@ -146,7 +146,8 @@ def send_email(recipient, subject, template, template_html, context=None,
146146
context = {}
147147
context['uri'] = '{scheme}://{host}'.format(
148148
scheme='https', host=settings.PRODUCTION_DOMAIN)
149-
send_email_task.delay(recipient, subject, template, template_html, context)
149+
send_email_task.delay(recipient=recipient, subject=subject, template=template,
150+
template_html=template_html, context=context, from_email=from_email)
150151

151152

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

0 commit comments

Comments
 (0)