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

Emails not sending (SMTP) #145

Open
nBLnzbbBBvSGEd opened this issue May 5, 2022 · 10 comments
Open

Emails not sending (SMTP) #145

nBLnzbbBBvSGEd opened this issue May 5, 2022 · 10 comments
Labels
bug Something isn't working

Comments

@nBLnzbbBBvSGEd
Copy link

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
Copy link
Member

GDay commented May 5, 2022

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
Copy link
Contributor

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.

@GDay GDay added the bug Something isn't working label May 24, 2023
@NinjaAway
Copy link

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, ["[email protected]"])

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
Copy link
Member

GDay commented Nov 5, 2024

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
Copy link

mike-mgt commented Nov 5, 2024

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
Copy link

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
      - [email protected] 
      - 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
Copy link

mike-mgt commented Nov 6, 2024

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

@NinjaAway
Copy link

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
Copy link

mike-mgt commented Nov 7, 2024

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants