chiefonboarding / ChiefOnboarding

Free and open-source employee onboarding platform. Onboard new hires through Slack or the web portal.
https://chiefonboarding.com
GNU Affero General Public License v3.0
682 stars 126 forks source link

Emails not sending (SMTP) #145

Open nBLnzbbBBvSGEd opened 2 years ago

nBLnzbbBBvSGEd commented 2 years ago

Hey,

I'm trialing out the self-hosted option via Docker, and running into some issues getting SMTP to work. I'm attempting to use Office365 (smtp.office365.com) using all of the environment variables listed on https://docs.chiefonboarding.com/integrations/email/

While using the feature to manually send the preboarding emails (People > New Hires > Settings Cog > Send pre-boarding email), it shows that the 'New hire has been notified.' though nothing comes through.

I have tried a few different options but cannot seem to find anything that works.

Are there any additional log files or settings that may assist?

Thank you

GDay commented 2 years ago

Hi, it should show an error message in the logs when it fails, unless the SMTP provider didn't return an error.

I know SMTP works, as one of my instances is using it. One caveat that might be an issue. In the docs there is written this:

EMAIL_USE_TLS=True
EMAIL_USE_SSL=True

You actually only need one of them. Could you try both (one at a time - remove the other one)?

megamaiku commented 2 years ago

I know this is old, but I was having a similar issue. The port I was given from my email provider was wrong and I defaulted to the one present in the ChiefOnboarding docs.

NinjaAway commented 2 weeks ago

Hello, Got the same issue. Very simple env. variables (EMAIL_HOST, EMAIL_PORT, EMAIL_USE_TLS, EMAIL_USE_SSL) and tried with ANYMAIL and SMTP (not the same on your webiste and email.md). The configuration (server and port) work on other servers.

When I tried test message that you mentionned in #331 : >>> send_mail("Test subject", "Test message", settings.DEFAULT_FROM_EMAIL, ["test-email@mycompany.com"])

Log from django :

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python3.11/site-packages/django/core/mail/__init__.py", line 87, in send_mail
    return mail.send()
           ^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/core/mail/message.py", line 299, in send
    return self.get_connection(fail_silently).send_messages([self])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/core/mail/backends/smtp.py", line 127, in send_messages
    new_conn_created = self.open()
                       ^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/core/mail/backends/smtp.py", line 85, in open
    self.connection = self.connection_class(
                      ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/smtplib.py", line 255, in __init__
    (code, msg) = self.connect(host, port)
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/smtplib.py", line 341, in connect
    self.sock = self._get_socket(host, port, self.timeout)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/smtplib.py", line 312, in _get_socket
    return socket.create_connection((host, port), timeout,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/socket.py", line 851, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.11/socket.py", line 836, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

Setup :

Docker version 25.03 Docker compose v2.24.5 ChiefOnboarding v2.2.3

Thank's for the support !

GDay commented 2 weeks ago

A connection timeout generally means that it could not reach the mail server. Do you have any sort of ip/region blocking on that server?

ChiefOnboarding is using Django defaults here and I don't know what I would need to change to fix this. This should be an issue with your mail server.

mike-mgt commented 2 weeks ago

A connection timeout generally means that it could not reach the mail server. Do you have any sort of ip/region blocking on that server?

ChiefOnboarding is using Django defaults here and I don't know what I would need to change to fix this. This should be an issue with your mail server.

This probably has less to do with IP/region blocking and more with port accessibility.

Hello, Got the same issue. Very simple env. variables (EMAIL_HOST, EMAIL_PORT, EMAIL_USE_TLS, EMAIL_USE_SSL) and tried with ANYMAIL and SMTP (not the same on your webiste and email.md). The configuration (server and port) work on other servers.

ChiefOnboarding email capabilities work, but as mentioned before, you should try using the default ports. What port are you currently using to connect to your email server?

NinjaAway commented 2 weeks ago

Hello,

Thank's for the help :)

Do you have any sort of ip/region blocking on that server?

No, I don't have any sorts of filter... Still works on other servers...

you should try using the default ports. What port are you currently using to connect to your email server?

Something very simple, here is an example of the environments variables inside my compose :

  web:
    container_name: Chief_web
    image: chiefonboarding/chiefonboarding:latest
    restart: always
    expose:
      - "8000"
    environment:
      - SMTP=True
      - DEFAULT_FROM_EMAIL=onboarding@mycompany.com 
      - EMAIL_HOST=smtp.mycompany.com
      - EMAIL_PORT=25
      - EMAIL_USE_TLS=True
      - EMAIL_USE_SSL=False

I've tried several configurations, mainly ANYMAIL, SMTP, EMAIL_USE_TLS and EMAIL_USE_SSL with different parameters, still got no results...

I was wondering if I've to open or tweak the port configurations of the container. Also tried with something like :

    expose:
      - "25"

or

    ports:
      - "25:25"

And yet, same issue... It works on other containers without it so, guess the snag is elsewhere.

Feel free to ask me details ! Again, thank's for the time and the support given.

mike-mgt commented 2 weeks ago

Have you tried using a different email provider? Something like Gmail or Outlook?

NinjaAway commented 2 weeks ago

Have you tried using a different email provider? Something like Gmail or Outlook?

Unfortunatly, I can't. My company is giving me a single point for mail server... So yes, I can't really reliate on others provider.

Do you have any example of SMTP working ? I think this is better this way to confirm there is not an issue with Chief, or at least, the mailing brick.

Thank's !

mike-mgt commented 2 weeks ago

Have you tried using a different email provider? Something like Gmail or Outlook?

Unfortunatly, I can't. My company is giving me a single point for mail server... So yes, I can't really reliate on others provider.

Do you have any example of SMTP working ? I think this is better this way to confirm there is not an issue with Chief, or at least, the mailing brick.

Thank's !

Yeah, just try another provider to test if there's something wrong with the connection. If you're using an enterprise environment, and your host machine is new (i.e., your other docker containers that do work with your email provider are in a different machine/IP/Mac Address, etc.) you may need to check if there are any policies preventing this interaction. I highly recommend testing this out with a service like Mailtrap, which offers a free account.

NinjaAway commented 2 weeks ago

Ok I'll try with Mailtrap I guess.

I've got no policies preventing any block path. Just to clarify, I got a virtual machine with docker and a working SMTP, I clone it, change IP address and put chief, it doesn't work. So yeah, I can try with an other provider but as I say, it works fine on all my server except this one.

I'll keep in touch if it works with Mailtrap, but in anycase, this is not the intended way nor the main issue.