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

Unable to send email with Office 365 SMTP #982

Closed
4 of 13 tasks
burak40 opened this issue Apr 3, 2023 · 16 comments
Closed
4 of 13 tasks

Unable to send email with Office 365 SMTP #982

burak40 opened this issue Apr 3, 2023 · 16 comments
Labels
question self-hosted Applies to self-hosted instances

Comments

@burak40
Copy link

burak40 commented Apr 3, 2023

🐛 Bug Report

I want to enable Login and for that I need to setup SMTP. I've set all these parameters
PWP__ENABLE_LOGINS: true
PWP__ALLOW_ANONYMOUS: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:pass
PWP__MAIL__SMTP_AUTHENTICATION:plain
PWP__MAIL__SMTP_STARTTLS:true
PWP__MAIL__OPEN_TIMEOUT:10
PWP__MAIL__READ_TIMEOUT:10
PWP__HOST_DOMAIN:azurewebsites.net
PWP__HOST_PROTOCOL:https
PWP__MAIL__MAILER_SENDER:email
PWP__DISABLE_SIGNUPS:false
PWP__MAIL__SMTP_ENABLE_STARTTLS_AUTO:false

I'm receiving this error Net::SMTPAuthenticationError (504 5.7.4 Unrecognized authentication type. I used login, same problem. Then I googled the 504 error code and followed this article https://stefanos.cloud/kb/how-to-allow-legacy-tls-smtp-clients-in-exchange-online/ but still not working. I deleted this parameter PWP__MAIL__SMTP_AUTHENTICATION and tried again, still not working with the same error.

🔬 How To Reproduce

Steps to reproduce the behavior:

  1. Forget Password and put e-mail

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

I'm getting Error 500

📈 Expected behavior

Send email from SMTP

📎 Additional context

@pglombardo
Copy link
Owner

Hi @burak40 - a quick look at that linked document says

if you choose option 1, i.e. the SMTP Auth client submission method, instead of smtp.office365.com you need to define smtp-legacy.office365.com as being your SMTP server.

Did you try setting that alternative address too?

@burak40
Copy link
Author

burak40 commented Apr 3, 2023

Yes, smtp-legacy.office365.com used also, same error

@assices
Copy link

assices commented May 5, 2023

Yes, smtp-legacy.office365.com used also, same error

Hello,

I have same problem, did you solve?

thanks

@burak40
Copy link
Author

burak40 commented May 7, 2023

Hi @assices , no still have this problem

@m4gn3to
Copy link

m4gn3to commented Jun 21, 2023

Hi.
I had the same problem.
I set the variable:
smtp_authentication: 'login'

Then I don't get the same error, but still can't send emails, now I face this error:

ArgumentError (SMTP From address may not be blank: nil):

I'm still trying to solve it.

Update:
mailer_sender: '"No Reply" noreply@myjob.fr'

Does the job !!

@pglombardo
Copy link
Owner

@m4gn3to has a good tip above. Worth validating if you have the time.

I'm traveling for the next few weeks and will revisit this once I'm back.

@pglombardo
Copy link
Owner

Hi all - just an update on the email story: 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
@CaptainSanders
Copy link

CaptainSanders commented Apr 22, 2024

I'm on version 1.40.6 should I try expressly with version 1.39.8?

When I have the config for Office 365 I get a 500 error in the interface (while Rails.application.config.action_mailer.smtp_settings gives the correct settings)
When I'm mailing with different settings (through a DA server i admin) mail is going through normally

this is the error on console:
/opt/PasswordPusher/vendor/bundle/ruby/3.2.0/gems/net-smtp-0.5.0/lib/net/smtp.rb:698:in `initialize': no implicit conversion of Symbol into Integer (TypeError)

  OpenSSL::SSL::SSLSocket.new socket, context
                              ^^^^^^^^^^^^^^^

@pglombardo
Copy link
Owner

I'm on version 1.40.6 should I try expressly with version 1.39.8?

The latest version (v1.40.6) will do as well. That new bundled tool should give us the exact error.

We have a known working configuration for 365 - does it work for you?

When you can, post the output from these steps.

@CaptainSanders
Copy link

Unfortunately those settings don't work for me

867a:/opt/PasswordPusher$ ./bin/pwpush console
Password Pusher Version: 1.40.6
Loading production environment (Rails 7.1.3.2)
irb(main):001> Rails.application.config.action_mailer.smtp_settings
=>
{:address=>"smtp.office365.com",
:port=>587,
:user_name=>"email@domain",
:password=>"PASSWORD",
:authentication=>"cram-md5",
:enable_starttls_auto=>true,
:open_timeout=>30,
:read_timeout=>30,
:openssl_verify_mode=>:none}
irb(main):002> TestMailer.send_test_email("testmail@domain").deliver_now

--> Configured FROM: address: '"Hosting" email@domain'
--> raise_delivery_errors is set to true in the configuration. This will raise an error if the email fails to send.
--> Attempting to send a test email to testmail@domain...
--> It seems that the Email sent successfully! Check destination inbox for the test email.

--> If you see an error, please paste this output into a GitHub issue for help.
--> Make sure that no sensitive data is included.
--> https://github.com/pglombardo/PasswordPusher/issues/new/choose

/opt/PasswordPusher/vendor/bundle/ruby/3.2.0/gems/net-smtp-0.5.0/lib/net/smtp.rb:698:in `initialize': no implicit conversion of Symbol into Integer (TypeError)

  OpenSSL::SSL::SSLSocket.new socket, context
                              ^^^^^^^^^^^^^^^

@CaptainSanders
Copy link

authentication :login and :cram-md5 (and :cram_md5), I've tried all of them with the same result.

@pglombardo pglombardo mentioned this issue Apr 24, 2024
8 tasks
@pglombardo
Copy link
Owner

pglombardo commented Apr 24, 2024

smtp.rb:698:in initialize': no implicit conversion of Symbol into Integer (TypeError)`

This has been a longtime pain. I've just release v1.40.7 which removes all defaults from SMTP settings. If you don't need the setting, comment it out in settings.yml and the code will have no reference.

This should reduce the number of settings in Rails.application.config.action_mailer.smtp_settings. Let me know if you have any more luck with this one.

@CaptainSanders
Copy link

You, sir, are a champion! The update did the the trick. I've commented out the following settings:
#PWP__MAIL__SMTP_ENABLE_STARTTLS_AUTO: 'true'
#PWP__MAIL__SMTP_OPEN_TIMEOUT: '30'
#PWP__MAIL__SMTP_READ_TIMEOUT: '30'
#PWP__MAIL__SMTP_OPENSSL_VERIFY_MODE: 'none'

Mail received without a hitch.

@pglombardo
Copy link
Owner

Wow excellent! That was a longtime bug. Great to hear that it works now.

@CaptainSanders
Copy link

Let's hope this effort also helps others. Thank you again for your effort and dedication.

P.S. The copyright is stuck on 2023, fix that in a future version ;)

@pglombardo
Copy link
Owner

Hi all - I'll close out this issue but if anything remains, please let me know!

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

5 participants