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

SMTP setup via env variables or encrypted config? #113

Closed
nebulade opened this issue Sep 24, 2023 · 8 comments
Closed

SMTP setup via env variables or encrypted config? #113

nebulade opened this issue Sep 24, 2023 · 8 comments

Comments

@nebulade
Copy link

nebulade commented Sep 24, 2023

Hi, I am looking into packaging docuseal for Cloudron and mostly it works, besides the email/smtp config. My first question here is around how docuseal picks configuration values.

The package code exports the relevant STMP settings via env variables: https://git.cloudron.io/cloudron/docuseal-app/-/blob/main/start.sh?ref_type=heads#L8

Those seem to be picked up but are not shown in the settings UI. I guess those are thus never put into the settings db (encrypted config), which as such is good, as they can then presumably be updated on app restart if the env varibales change.

Is my observation correct here and is there any way then to prohibit showing the mail settings in the config UI to ensure a user will not overwrite those?

@AlexBTurchyn
Copy link
Contributor

Hi @nebulade i think it would be best to have users configure SMTP via the settings UI instead of the ENV variables to make the installation process easier for everyone. There is only one required ENV variable - SECRET_KEY_BASE (rails encryption key). DATABASE_URL can be used to point the app to PG database - but if not specified it will run in an Sqlite DB.

Let me know if that makes sense or if you need SMTP via env for some particular reason

@AlexBTurchyn
Copy link
Contributor

UPDATE:
I spent some time to look how cloudron apps work and it seems like they all can share the same SMTP settings - in this case configuring SMTP via ENV makes sense and actually it will be easier for users to have it configured this way instead of the settings UI.

When SMTP is configured via ENV the smtp settings UI is still displayed - but the form is empty and those values are not copied into DB (which is probably good for the users).

I've just added a commit to hide smtp settings from the UI when env variables are used.
Will be released in the next version today.

@nebulade
Copy link
Author

Thanks for the fast response! Great to have that change then and thanks for the clarification on how it works. And yes in Cloudron the SMTP settings are provided by the platform into the app to avoid having the user to configure those for each app, so with your change this will work very well.

Besides that, there is still some things for me to work out on how to set this up. Sending an email results in the following resolving issue, but this may just be a quirk in Cloudron then. I am not a rails expert, so have to read up.

15:43:51 - E, [2023-09-24T13:43:51.420970 #8] ERROR -- : [ActiveJob] [ActionMailer::MailDeliveryJob] [2d08cbfe-77a7-46d8-a93e-11a596e0fcd9] Error performing ActionMailer::MailDeliveryJob (Job ID: 2d08cbfe-77a7-46d8-a93e-11a596e0fcd9) from Async(default) in 133.84ms: SocketError (getaddrinfo: Name or service not known):
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:231:in `getaddrinfo'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:231:in `foreach'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/3.2.0/socket.rb:635:in `tcp'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:643:in `tcp_socket'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:656:in `do_start'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/net-smtp-0.3.3/lib/net/smtp.rb:611:in `start'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/smtp.rb:109:in `start_smtp_session'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/smtp.rb:100:in `deliver!'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/mail-2.8.1/lib/mail/message.rb:269:in `deliver!'
15:43:51 - /root/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actionmailer-7.0.7/lib/action_mailer/message_delivery.rb:109:in `block in deliver_now!'
......

@AlexBTurchyn
Copy link
Contributor

AlexBTurchyn commented Sep 24, 2023

https://git.cloudron.io/cloudron/docuseal-app/-/blob/main/start.sh?ref_type=heads#L8

@nebulade based on the start.sh file it seems like you pass FROM address (email) into the SMTP_ADDRESS docuseal env variable - this variable should contain a DNS name of the host or IP address of the SMTP server (that's why you receive getaddrinfo: Name or service not know error)

Replacing it with CLOUDRON_MAIL_SMTP_SERVER should fix the error

@nebulade
Copy link
Author

Ah thanks for the second pair of eyes. I've set now the correct env variable with email sending success and can confirm that the email settings view is also neatly disabled if env vars are set. Looks like I can release a Cloudron package for our users then tomorrow. Great app!

@AlexBTurchyn
Copy link
Contributor

AlexBTurchyn commented Sep 25, 2023 via email

@nebulade
Copy link
Author

Just for reference, the initial app package is now available for Cloudron users. Great app!

@omohokcoj
Copy link
Contributor

Hi @nebulade the latest 1.6.2 version introduces a new dependency - redis-server, which should be installed here:
https://git.cloudron.io/cloudron/docuseal-app/-/blob/main/Dockerfile?ref_type=heads#L10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants