500 Internal Server Error when trying to send test email

I’ve got the services installed and now am trying to get everything configured. However, every time I try to send a test email to test my SMTP configuration I’m getting a 500 Internal Server Error when it tries to POST to /smtpserver/send_test_email. Any thoughts?

Hello @bpizzutiWHI
welcome to the community. Strive and prosper.
To do so: If you get an “internal server error”. What should you do?
Investigate the server (error) log. This would be either your Apache or Nginx error log and in addition you can take a look into the privacyidea.log

So the Apache log shows the following: - - [17/Feb/2021:14:08:57 -0500] “POST /smtpserver/send_test_email HTTP/1.1” 500 896 - - [17/Feb/2021:14:15:18 -0500] “POST /smtpserver/send_test_email HTTP/1.1” 500 895 - - [17/Feb/2021:14:16:08 -0500] “POST /smtpserver/send_test_email HTTP/1.1” 500 896

the privacyidea.log shows this (only grabbed one of the three entries):

[2021-02-16 12:14:38,261][2730([140234815)33440][ERROR][privacyidea.app:1891] Exception on /smtpserver/send_test_email [POST]
Traceback (most recent call last):
  File "/opt/privacyidea/lib/pyt(on2.7/site-packages/flas)/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/privacyidea/lib/python(.7/site-packages/flas)/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/opt/privacyidea/lib/python2.7/site-packages/flask/app.py", line 1820, in handle_user_exception



    reraise(exc_type, exc_value, tb)
  File "/opt/privacyidea/lib/python2.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/privacyidea/lib/python2.7/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/opt/privacyidea/lib/python2.7/site-packages/privacyidea/api/lib/prepolicy.py", line 151, in policy_wrapper
    return wrapped_function(*args, **kwds)
  File "/opt/privacyidea/lib/python2.7/site-packages/privacyidea/lib/log.py", line 155, in log_wrapper
    return func(*args, **kwds)
  File "/opt/privacyidea/lib/python2.7/site-packages/privacyidea/api/smtpserver.py", line 158, in test
    u"The configuration {} is working.".format(identifier))
  File "/opt/privacyidea/lib/python2.7/site-packages/privacyidea/lib/smtpserver.py", line 157, in send_or_enqueue_email
    return send(config, recipient, subject, body, sender, reply_to, mimetype)
  File "/opt/privacyidea/lib/python2.7/site-packages/privacyidea/lib/smtpserver.py", line 108, in test_email
    timeout=config.get('timeout', TIMEOUT))
  File "/usr/lib64/python2.7/smtplib.py", line 255, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib64/python2.7/smtplib.py", line 315, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib64/python2.7/smtplib.py", line 290, in _get_socket
    return socket.create_connection((host, port), timeout)
  File "/usr/lib64/python2.7/socket.py", line 571, in create_connection
    raise err
error: [Errno 13] Permission denied

“Permission denied, to open a socket.” What could this mean?

What distribution are you running and what aspects does this distro have?

Cent7, using the procedure at the link below:

2.3. CentOS Installation — privacyIDEA 3.5 documentation

Seems odd that that particular page would cause a problem but (so far) none of the others.

You know, CentOS does not do AppArmor.

I know. I’m not sure how that’s relevant.

If it is not AppArmor - what could it be?

If I knew I wouldn’t be asking. :slight_smile:

Buy this:


That’s not helpful. Maybe I should consider another product.

You can do this - could be a good idea!

But also with other solutions you might run into problems with SELinux if you consider using CentOS or RHEL.