Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SSL/TLS in SMTP server #231

Closed
carlos-wong opened this issue Jul 6, 2019 · 9 comments

Comments

Projects
None yet
2 participants
@carlos-wong
Copy link

commented Jul 6, 2019

Please post on our forums: https://discuss.overhang.io for questions about using tutor.

https://discuss.overhang.io/t/smtp-config-use/84

Posts that are not a bug report or a feature/enhancement request will not be addressed on this issue tracker.

I am not sure it is a but or not?
I am follow the doc https://docs.tutor.overhang.io/configuration.html#smtp.

But the lms_worker logs aways show raise SMTPServerDisconnected("Connection unexpectedly closed")

I curious about the ACTIVATE_SMTP, should I set to true ? I am configed true and false but the log are same.

I am checked #215 and checked my config by use a test script to send email

@carlos-wong

This comment has been minimized.

Copy link
Author

commented Jul 6, 2019

this is my test script: https://gist.github.com/carlos-wong/7a70e3f9fa3cbedca39686d32faddd71. I am use my account info and the email is sent success.

@regisb

This comment has been minimized.

Copy link
Collaborator

commented Jul 6, 2019

Hi @carlos-wong! Thanks for the more detailed issue description 😉

Did you modify the email configuration? If yes, how?

@carlos-wong

This comment has been minimized.

Copy link
Author

commented Jul 6, 2019

Hi @regisb , I edit the email config by modify the config.yml. Then save the config , and restart the services. I checking the version. I am followed the doc by install 3.4.3, now I am installing 3..5.3

@carlos-wong

This comment has been minimized.

Copy link
Author

commented Jul 6, 2019

I am upgraded to 3.5.3 the result is same.

Here is the log

lms_worker_1      | Traceback (most recent call last):
lms_worker_1      |   File "/openedx/edx-platform/common/djangoapps/student/tasks.py", line 23, in send_activation_email
lms_worker_1      |     mail.send_mail(subject, message, from_address, [dest_addr], fail_silently=False)
lms_worker_1      |   File "/openedx/venv/local/lib/python2.7/site-packages/django/core/mail/__init__.py", line 62, in send_mail
lms_worker_1      |     return mail.send()
lms_worker_1      |   File "/openedx/venv/local/lib/python2.7/site-packages/django/core/mail/message.py", line 348, in send
lms_worker_1      |     return self.get_connection(fail_silently).send_messages([self])
lms_worker_1      |   File "/openedx/venv/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 104, in send_messages
lms_worker_1      |     new_conn_created = self.open()
lms_worker_1      |   File "/openedx/venv/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 64, in open
lms_worker_1      |     self.connection = self.connection_class(self.host, self.port, **connection_params)
lms_worker_1      |   File "/usr/lib/python2.7/smtplib.py", line 256, in __init__
lms_worker_1      |     (code, msg) = self.connect(host, port)
lms_worker_1      |   File "/usr/lib/python2.7/smtplib.py", line 317, in connect
lms_worker_1      |     (code, msg) = self.getreply()
lms_worker_1      |   File "/usr/lib/python2.7/smtplib.py", line 368, in getreply
lms_worker_1      |     raise SMTPServerDisconnected("Connection unexpectedly closed")
lms_worker_1      | SMTPServerDisconnected: Connection unexpectedly closed
lms_worker_1      | 2019-07-06 06:12:51,967 ERROR 1 [celery.worker.job] log.py:282 - Task student.tasks.send_activation_email[04d91b91-716f-4339-b10d-eb3baff394fb] raised unexpected: Exception()
lms_worker_1      | Traceback (most recent call last):
lms_worker_1      |   File "/openedx/venv/local/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task
lms_worker_1      |     R = retval = fun(*args, **kwargs)
lms_worker_1      |   File "/openedx/venv/local/lib/python2.7/site-packages/celery/app/trace.py", line 438, in __protected_call__
lms_worker_1      |     return self.run(*args, **kwargs)
lms_worker_1      |   File "/openedx/edx-platform/common/djangoapps/student/tasks.py", line 50, in send_activation_email
lms_worker_1      |     raise Exception
lms_worker_1      | Exception
@regisb

This comment has been minimized.

Copy link
Collaborator

commented Jul 6, 2019

I edit the email config by modify the config.yml
So... I suppose you edited SMTP_USERNAME, SMTP_PASSWORD, SMTP_HOST and SMTP_PORT. Is that correct?

Your script uses SSL authentication for SMTP, and as you mentioned this is not supported (yet) by Tutor. So let's try to use SSL.

Please try the following:

  1. Add EMAIL_USE_SSL = True to env/apps/openedx/settings/lms/production.py
  2. Restart lms worker: tutor local restart lms_worker
  3. Try again.

Does it solve your problem?

@carlos-wong

This comment has been minimized.

Copy link
Author

commented Jul 6, 2019

@regisb yes. it is miss the ssl config. I just curious about the config.yml doc didn't describe the smtp ssl method.

@carlos-wong carlos-wong closed this Jul 6, 2019

@regisb

This comment has been minimized.

Copy link
Collaborator

commented Jul 6, 2019

Wait! Don't close this issue! This is probably a feature that we want to add to Tutor.

@regisb regisb reopened this Jul 6, 2019

@regisb regisb changed the title smtp config not work Add support for SSL/TLS in SMTP server Jul 6, 2019

@regisb

This comment has been minimized.

Copy link
Collaborator

commented Jul 7, 2019

@carlos-wong Would you mind testing if email sending still works if you replace EMAIL_USE_SSL by EMAIL_USE_TLS? Those two settings are contradictory and I would rather implement just one of them.

regisb added a commit that referenced this issue Jul 7, 2019

Add support for external SMTP server with TLS
Note that this setting will not work with the default namshi smtp server
shipped with tutor.

Close #231.

regisb added a commit that referenced this issue Jul 7, 2019

Add support for external SMTP server with TLS
Note that this setting will not work with the default namshi smtp server
shipped with tutor.

Close #231.

@regisb regisb closed this in edbf819 Jul 7, 2019

regisb added a commit that referenced this issue Jul 7, 2019

Add support for external SMTP server with TLS
Note that this setting will not work with the default namshi smtp server
shipped with tutor.

Close #231.
@carlos-wong

This comment has been minimized.

Copy link
Author

commented Jul 7, 2019

@regisb Hi, I am test on my smtp service. if I change to EMAIL_USE_TLS, it will fail

lms_worker_1      | Traceback (most recent call last):
lms_worker_1      |   File "/openedx/edx-platform/common/djangoapps/student/tasks.py", line 23, in send_activation_email
lms_worker_1      |     mail.send_mail(subject, message, from_address, [dest_addr], fail_silently=False)
lms_worker_1      |   File "/openedx/venv/local/lib/python2.7/site-packages/django/core/mail/__init__.py", line 62, in send_mail
lms_worker_1      |     return mail.send()
lms_worker_1      |   File "/openedx/venv/local/lib/python2.7/site-packages/django/core/mail/message.py", line 348, in send
lms_worker_1      |     return self.get_connection(fail_silently).send_messages([self])
lms_worker_1      |   File "/openedx/venv/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 104, in send_messages
lms_worker_1      |     new_conn_created = self.open()
lms_worker_1      |   File "/openedx/venv/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 64, in open
lms_worker_1      |     self.connection = self.connection_class(self.host, self.port, **connection_params)
lms_worker_1      |   File "/usr/lib/python2.7/smtplib.py", line 256, in __init__
lms_worker_1      |     (code, msg) = self.connect(host, port)
lms_worker_1      |   File "/usr/lib/python2.7/smtplib.py", line 317, in connect
lms_worker_1      |     (code, msg) = self.getreply()
lms_worker_1      |   File "/usr/lib/python2.7/smtplib.py", line 368, in getreply
lms_worker_1      |     raise SMTPServerDisconnected("Connection unexpectedly closed")
lms_worker_1      | SMTPServerDisconnected: Connection unexpectedly closed
lms_worker_1      | 2019-07-07 14:30:10,001 ERROR 1 [celery.worker.job] log.py:282 - Task student.tasks.send_activation_email[6445a871-f4e7-483b-bdad-388d9a9ff663] raised unexpected: Exception()
lms_worker_1      | Traceback (most recent call last):
lms_worker_1      |   File "/openedx/venv/local/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task
lms_worker_1      |     R = retval = fun(*args, **kwargs)
lms_worker_1      |   File "/openedx/venv/local/lib/python2.7/site-packages/celery/app/trace.py", line 438, in __protected_call__
lms_worker_1      |     return self.run(*args, **kwargs)
lms_worker_1      |   File "/openedx/edx-platform/common/djangoapps/student/tasks.py", line 50, in send_activation_email
lms_worker_1      |     raise Exception
lms_worker_1      | Exception

I think you should expose this two options let the user choose

@regisb regisb reopened this Jul 7, 2019

@regisb regisb closed this in d7477ba Jul 7, 2019

xavierchan added a commit to xavierchan/tutor that referenced this issue Jul 9, 2019

Add support for external SMTP server with TLS
Note that this setting will not work with the default namshi smtp server
shipped with tutor.

Close overhangio#231.

regisb added a commit that referenced this issue Jul 11, 2019

v3.6.0 (2019-07-11)
- [Feature] Modify ``createuser`` commands to define a password from the
command line
- [Improvement] Better yaml value parsing from command line
- [Feature] Add `dev exec` command
- [Bugfix] Fix incorrect notes settings definition
- [Improvement] Make it possible to start/stop/reboot a selection of
services
- [Improvement] Add `local/k8s reboot` commands
- [Improvement] Add `-U/--unset` option to `config save`
- [Bugfix] Fix insecure static asset loading when web proxy is enabled
- [Improvement] Rename `SECRET_KEY` configuration parameter to
`OPENEDX_SECRET_KEY`
- [Improvement] Add support for SSL and TLS in external SMTP server
(#231)
- [Bugfix] Fix missing video transcripts in LMS (#229)
- [Improvement] Make it possible to enable/disable multiple plugins at
once
- [Improvement] Add a few local and k8s patches for plugins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.