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

E-mail not sending on docker enviroment #1355

Closed
2 of 13 tasks
MkosterNet4it opened this issue Aug 14, 2023 · 22 comments
Closed
2 of 13 tasks

E-mail not sending on docker enviroment #1355

MkosterNet4it opened this issue Aug 14, 2023 · 22 comments
Labels
question self-hosted Applies to self-hosted instances

Comments

@MkosterNet4it
Copy link

🐛 Bug Report

Mails not sending on custom docker enviroment, getting Error #500

🔬 How To Reproduce

Steps to reproduce the behavior:

  1. setup with docker image pglombardo/pwpush-postgres:release
  2. configure db connection and environment
  3. register new user -> no registration mail send
  4. test with forgot password -> no mail send

Code sample

  PWP__ENABLE_LOGINS: "true"
  PWP__MAIL__RAISE_DELIVERY_ERRORS: "true"
  PWP__MAIL__SMTP_ADDRESS: "smtp.office365.com"
  PWP__MAIL__SMTP_PORT: "587"
  PWP__MAIL__SMTP_USER_NAME: "_email_"
  PWP__MAIL__SMTP_PASSWORD: "_password_"
  PWP__MAIL__SMTP_AUTHENTICATION: "login"
  PWP__MAIL__SMTP_STARTTLS: "false"
  PWP__MAIL__SMTP_ENABLE_STARTTLS_AUTO: "false"
  PWP__MAIL__OPEN_TIMEOUT: "10"
  PWP__MAIL__READ_TIMEOUT: "10"
  PWP__HOST_DOMAIN: "_fqdn_"
  PWP__HOST_PROTOCOL: "https"

Environment

Where are you running/using Password Pusher?

  • pwpush.com
  • Docker
    • pwpush-ephemeral
    • pwpush-mysql
    • pwpush-postgres
    • custom image
  • Heroku
  • Digital Ocean
  • Microsoft Azure
  • Google Cloud
  • AWS
  • Source Code
  • Other (please specify)

If applicable, what version of Password Pusher?

Screenshots

image

📈 Expected behavior

E-mails being sent to the users, so that we can create the accounts for our company.

📎 Additional context

Rails.application.config.action_mailer.smtp_settings
{:address=>"smtp.office365.com",
 :port=>587,
 :user_name=>"_email_",
 :password=>"_password_",
 :authentication=>"login",
 :enable_starttls_auto=>true,
 :open_timeout=>10,
 :read_timeout=>10}
irb(main):020:1* Mail.deliver do
irb(main):021:1*   to 'email'
irb(main):022:1*   from 'email'
irb(main):023:1*   subject 'testing mail'
irb(main):024:1*   body 'testing mail'
irb(main):025:0> end
/usr/local/lib/ruby/3.2.0/socket.rb:1217:in `__connect_nonblock': Address not available - connect(2) for [::1]:25 (Errno::EADDRNOTAVAIL)

Hope anyone can help me figure this out

@github-actions
Copy link

Hello @MkosterNet4it, thanks for contributing to the Password Pusher community! We will respond as soon as possible.

@pglombardo
Copy link
Owner

pglombardo commented Aug 14, 2023

Hi @MkosterNet4it a couple ideas:

  1. Office365 removed basic authentication I believe. Take a look at these issues for more information:
  2. Did you also set the required PWP__MAIL__MAILER_SENDER? This has to be valid email format e.g. '"Password Pusher" <pglombardo@pwpush.com>'
  3. Try setting PWP__MAIL__SMTP_ENABLE_STARTTLS_AUTO=false - this has shown to fix the 500 in some cases (docs)
  4. And finally, if you could retrieve the stack trace from the container in /opt/PasswordPusher/logs that would show us exactly what the SMTP error is in the application

Re:

/usr/local/lib/ruby/3.2.0/socket.rb:1217:in `__connect_nonblock': Address not available - connect(2) for [::1]:25 (Errno::EADDRNOTAVAIL)

It's odd that it attempted to connect on port 25 here despite configuring 587...

Hopefully this will put us on the right path. Let me know.

@MkosterNet4it
Copy link
Author

Hi @MkosterNet4it a couple ideas:

  1. Office365 removed basic authentication I believe. Take a look at these issues for more information:

  2. Did you also set the required PWP__MAIL__MAILER_SENDER? This has to be valid email format e.g. '"Password Pusher" <pglombardo@pwpush.com>'

  3. Try setting PWP__MAIL__SMTP_ENABLE_STARTTLS_AUTO=false - this has shown to fix the 500 in some cases (docs)

  4. And finally, if you could retrieve the stack trace from the container in /opt/PasswordPusher/logs that would show us exactly what the SMTP error is in the application

Re:

/usr/local/lib/ruby/3.2.0/socket.rb:1217:in `__connect_nonblock': Address not available - connect(2) for [::1]:25 (Errno::EADDRNOTAVAIL)

It's odd that it attempted to connect on port 25 here despite configuring 587...

Hopefully this will put us on the right path. Let me know.

Hey @pglombardo I just checked the error log and found this

[2023-08-15T06:56:14.581162 #199] FATAL -- : [e6b404e8-ff01-4f6a-864c-ca3195ca5b44]
[e6b404e8-ff01-4f6a-864c-ca3195ca5b44] Net::SMTPSyntaxError (504 5.7.4 Unrecognized authentication type [AM0PR10CA0090.EURPRD10.PROD.OUTLOOK.C):
[e6b404e8-ff01-4f6a-864c-ca3195ca5b44]
[e6b404e8-ff01-4f6a-864c-ca3195ca5b44] app/controllers/application_controller.rb:14:in `custom_set_locale_from_url'

As far as I can read of this I need to change the authentication type.

@MkosterNet4it
Copy link
Author

Hey @pglombardo,

I changed some mail settings as I found we have another smtp server, right now i'm getting this message.

[2023-08-15T11:33:05.483034 #208] FATAL -- : [89bae59d-22d6-443d-9470-12c86ac42c93]
[89bae59d-22d6-443d-9470-12c86ac42c93] Net::ReadTimeout (Net::ReadTimeout with #<Socket:(closed)>):
[89bae59d-22d6-443d-9470-12c86ac42c93]
[89bae59d-22d6-443d-9470-12c86ac42c93] app/controllers/application_controller.rb:14:in `custom_set_locale_from_url'

This is a totally new message that I haven't seen before.

@pglombardo
Copy link
Owner

That means that the container couldn't transfer data over the network. But without more info, it's hard to tell where and why.

What did you do to get that error message? Could you post the full stack trace?

@MkosterNet4it
Copy link
Author

Hey @pglombardo,

What I did was click on the button "Didn't receive confirmation instructions?"
Please let me know how to post the full stack trace as the previous send message was the only thing I got when doing either vim and cat on the production.log

@gregoryca
Copy link

Sadly i'm having the same problem. I can post a stacktrace if needed.

I have tried a Azure Container Instance deployment, and a Azure App Service/Web App route. Both deployments worked fine (i deploy from terraform). When i enable the login functionality, and sign up it won't work because PWPush never sends the confirmation email. This also happens in my infra at home where i run docker(compose) on a plain linux machine. It keeps trying to send mail from port 25 while it should use port 465.

@gregoryca
Copy link

Is there by any chance any progress on this issue ? Thanks !

@pglombardo
Copy link
Owner

Hi @gregoryca -

Sorry to hear these issues are still happening for some.

Could you shell into the container, start a console (rails console) and run Rails.application.config.action_mailer.smtp_settings and post the filtered output here?

@gregoryca
Copy link

mail error rails
The container keeps mailing over port 25, while i've specified a different port in my docker-compose. Same issue on my ACI

@pglombardo
Copy link
Owner

What's odd is that it says localhost and port 25 - neither of which are in your config.

Could you set both of the following environment variable for your container, restart it and then try the test again?

PWP__MAIL__SMTP_STARTTLS=false
PWP__MAIL__SMTP_ENABLE_STARTTLS_AUTO=false

@pglombardo
Copy link
Owner

Also why the literal quotes (\") in the username?

@TargetCrafter
Copy link

I get these same 500 errors in my container. I've tried the starttls settings and i also tried to get the Rails config, but i get the following error.

/opt/PasswordPusher $ Rail console
/bin/sh: Rail: not found

@pglombardo
Copy link
Owner

Hi @TargetCrafter - The command should be rails - lowercase and plural.

If you get a 500, find the error stack trace in the container log and post it here.

@TargetCrafter
Copy link

I got the following logs in docker:
Errno::EADDRNOTAVAIL (Address not available - connect(2) for nil port 587)

I find this odd because i have configured to use port 2525 for smtp in my env file:

export PWP__MAIL_SMTP_ADDRESS='XXXXX'
export PWP__MAIL_SMTP_PORT=2525
export PWP__MAIL__RAISE_DELIVERY_ERRORS=true
export PWP__MAIL_SMTP_USER_NAME='XXXXX'
export PWP__MAIL_SMTP_PPASSWORD='XXXXX'
export PWP__MAIL__SMTP_AUTHENTICATION=plain
export PWP__MAIL__SMTP_STARTTLS=false
export PWP__MAIL__SMTP_ENABLE_STARTTLS_AUTO=false
export PWP__MAIL__MAILER_SENDER='"XXXXX" <XXXXX>'

@pglombardo
Copy link
Owner

@TargetCrafter there are some errors in your environment variable names. PWP__MAIL__ must always have double underscores.

These:

export PWP__MAIL_SMTP_ADDRESS='XXXXX'
export PWP__MAIL_SMTP_PORT=2525
export PWP__MAIL_SMTP_USER_NAME='XXXXX'
export PWP__MAIL_SMTP_PPASSWORD='XXXXX' # <--- also spelling error here 'ppassword'

should be

export PWP__MAIL__SMTP_ADDRESS='XXXXX'
export PWP__MAIL__SMTP_PORT=2525
export PWP__MAIL__SMTP_USER_NAME='XXXXX'
export PWP__MAIL__SMTP_PASSWORD='XXXXX'  

Documentation here if you want to copy paste for simplicity.

@TargetCrafter
Copy link

Thanks, that fixed it. And now I feel stupid xD

@pglombardo
Copy link
Owner

Thanks, that fixed it. And now I feel stupid xD

Excellent! But don't feel that way. Those env vars could definitely be more user friendly...

@gregoryca
Copy link

Excuse my for my late comment. I will make the changes, and see if that changes the behaviour. Why the quotes are being showed, is a good question and something i can't clarify sadly. I will try to create another mail address/display name.

Maybe it's the double quotes that's throwing me for a loop

@pglombardo
Copy link
Owner

Hi all - just an update on the email issues: in v1.39.8, I added a tool to test email configurations. Could you update to that version and try this out?

It should reveal exactly where the issue is...

@pglombardo pglombardo added the self-hosted Applies to self-hosted instances label Apr 18, 2024
@pglombardo
Copy link
Owner

Hi all - thankfully it seems issues with email seems to have been resolved. I'll close out this issue but if anything remains, please feel free to open a new issue and I'll take a look. Thanks for the help all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question self-hosted Applies to self-hosted instances
Projects
None yet
Development

No branches or pull requests

4 participants