invoiceninja / dockerfiles

Docker files for Invoice Ninja
https://hub.docker.com/r/invoiceninja/invoiceninja
GNU General Public License v2.0
420 stars 269 forks source link

SMTP Configuration (Helm) #399

Closed schroedt closed 3 years ago

schroedt commented 3 years ago

Hi there,

how can I configure mail, after completing installation (using Helm)?

kubectl create configmap custom-env --from-file=./conf/env.yaml -n invoice-ninja -o yaml --dry-run=client | kubectl apply -f -

helm upgrade --install invoiceninja invoiceninja/invoiceninja --namespace invoice-ninja \
              --set appURL=*** \
              --set requireHttps=true \
              --set trustedProxy='*' \
              --set mailer=smtp \
              --set extraEnvVarsCM=custom-env \
              --set appKey=*** \
              --set redis.auth.password=** \
              --set userEmail=** \
              --set userPassword=** \
              --set mariadb.enabled=false \
              --set externalDatabase.host=***\
              --set externalDatabase.user=** \
              --set externalDatabase.password=*** \
              --set externalDatabase.database=** \
              --set externalDatabase.port=3306

./conf/env.yaml

MAIL_MAILER=smtp
MAIL_HOST=smtp.***
MAIL_PORT=***
MAIL_USERNAME=postmaster@***
MAIL_PASSWORD=***
MAIL_ENCRYPTION=TLS
MAIL_FROM_ADDRESS='payment@***'
MAIL_FROM_NAME='*** | Payments'
lwj5 commented 3 years ago

Please look at https://github.com/invoiceninja/dockerfiles/tree/master/charts/invoiceninja#setting-environment-variables

I’ll go ahead and close this as it is not an issue

schroedt commented 3 years ago

Hi @lwj5 ,

I dont realy get the documentation; is it as followed?

helm upgrade --install invoiceninja invoiceninja/invoiceninja --namespace invoice-ninja \
              --set appURL=*** \
              --set requireHttps=true \
              --set trustedProxy='*' \
              --set mailer=smtp \
              --set extraEnvVarsCM=custom-env \
              --set appKey=*** \
              --set redis.auth.password=** \
              --set userEmail=** \
              --set userPassword=** \
              --set mariadb.enabled=false \
              --set externalDatabase.host=***\
              --set externalDatabase.user=** \
              --set externalDatabase.password=*** \
              --set externalDatabase.database=** \
              --set extraEnvVars:
                 - name: MAIL_HOST
                   value: 'smtp.mailtrap.io'
                 - name: MAIL_PORT
                   value: '123456'
                 - …

How about line brakes?

lwj5 commented 3 years ago

The example shown is in yaml format, if you want to use command line options. You will have to use

--set extraEnvVars[0].name=xxx --set extraEnvVars[0].value=xxx

Change 0 to 1,2,3... if you have more env.

Alternatively, I suggest you use yaml file:

https://github.com/invoiceninja/dockerfiles/tree/master/charts/invoiceninja#installing-with-arguments

You may want to read the helm documentation at https://helm.sh/docs/helm/helm_install/

schroedt commented 3 years ago

Hi @lwj5,

slack wont be available for others, which might have the same issue. Anyway, where do I find slack information for contacting?

Following fails:

helm upgrade --install invoiceninja invoiceninja/invoiceninja --namespace invoice-ninja \
              --set appURL=https://***
              --set requireHttps=*** \
              --set trustedProxy='*' \
              --set mailer=smtp \
              --set extraEnvVars[0].name=MAIL_HOST \
              --set extraEnvVars[0].value=*** \
              --set extraEnvVars[1].name=MAIL_PORT \
              --set extraEnvVars[1].value=123 \
              --set extraEnvVars[2].name=MAIL_USERNAME \
              --set extraEnvVars[2].value=*** \
              --set extraEnvVars[3].name=MAIL_PASSWORD \
              --set extraEnvVars[3].value=*** \
              --set extraEnvVars[4].name=MAIL_ENCRYPTION \
              --set extraEnvVars[4].value=TLS \
…

v1.Deployment.Spec: v1.DeploymentSpec.Template: v1.PodTemplateSpec.Spec: v1.PodSpec.Containers: []v1.Container: v1.Container.v1.Container.Env: []v1.EnvVar: v1.EnvVar.Value: ReadString: expects " or n, but found 1, error found in #10 byte of ...|,"value":123},{"name|..., bigger context ...|ue":"smtp.****"},{"name":"MAIL_PORT","value":123},{"name":"MAIL_USERNAME","value":"mail@removed|...

I tried it with following items (all failed):

--set extraEnvVars[1].value=123 \
--set extraEnvVars[1].value=\"123\" \
--set extraEnvVars[1].value='123' \

Installing with arguments is missing a straight forward explanation for using a reference for extraEnvVar, which I seem need to use. Normal variables are fine, but that additional parameter referencing something undefined is very trouble-some.

lwj5 commented 3 years ago

You can find the slack link here. https://github.com/invoiceninja/invoiceninja#were-on-slack-join-us-at-slackinvoiceninjacom-or-if-you-like-stackoverflow

I just relooked at your command in your first post. You have done everything correctly in your first post, I overlooked the create configmap line.

you just need to edit the configmap custom-env and restart the invoiceninja pod.

You can ignore my post above

the only thing you need to do if you do change the values in the configmap is to restart the invoiceninja pods for the changes to take effect

schroedt commented 3 years ago

I just relooked at your command in your first post.

you just need to edit the configmap custom-env and restart the invoiceninja pod.

You can ignore my post above

Is there any way for testing mailing? When sending an invoice I get an authentication denied. But I do not know, which mailserver invoice-ninja uses; mine does not log any error and credentials are correct..

grafik

lwj5 commented 3 years ago

I found this post by David https://forum.invoiceninja.com/t/how-do-i-troubleshoot-email-configuration/5427/16 Not sure if the DB will yield any new info

I’m not too familiar with checking which server it uses, maybe @turbo124 can advise

schroedt commented 3 years ago

Hi @lwj5,

I am on slack now as well. I do get an error but don't know why. Pod-Logs stay empty.

schroedt commented 3 years ago

I found this post by David https://forum.invoiceninja.com/t/how-do-i-troubleshoot-email-configuration/5427/16 Not sure if the DB will yield any new info

I’m not too familiar with checking which server it uses, maybe @turbo124 can advise

grafik

grafik

» Sames as on the UI (not stating used mail server, configuration, user etc.):

grafik

lwj5 commented 3 years ago

try running this

kubectl exec -it -n <namespace> <pod_name> -- env | grep MAIL

if it shows you the correct config then wait for David to reply as I'm not too familiar with IN inner workings

schroedt commented 3 years ago

Hi @lwj5,

parameters are correct, but it is still not working. I tested the same credentials from another pod (using Gitbucket) and they work. I am thinking about the MAIL_ENCRYPTION option causing trouble (activated at the other software as well): grafik

kubectl -n invoice-ninja exec -ti pod/invoiceninja-66cd5cd5d8-bwdwg -c invoiceninja -- env | grep MAIL
env.yaml=MAIL_MAILER=smtp
MAIL_HOST=**.****
MAIL_PORT=123
MAIL_USERNAME=**@****
MAIL_PASSWORD=****
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS='*****@****'
MAIL_FROM_NAME='text'
MAIL_MAILER=smtp
IN_USER_EMAIL=**@****

it looks like the file is not properly read:

kubectl -n invoice-ninja edit configmap/custom-env

apiVersion: v1
data:
  env.yaml: |
    MAIL_MAILER=smtp
    MAIL_HOST=**.***
    MAIL_PORT=123
    MAIL_USERNAME=**@***
    MAIL_PASSWORD=***
    MAIL_ENCRYPTION=tls
    MAIL_FROM_ADDRESS='**@****'
    MAIL_FROM_NAME='***'
kind: ConfigMap
metadata:
…

Is there any way for getting the actually used mail server and log details? image.debug=true and debug=true make no difference; very hard to debug, when being blind.

Further, I do think anything I configured is not used at all.

schroedt commented 3 years ago

Found the issue:

extraEnv is never reflected within the Helm chart. The only option for setting SMTP is using values.yaml. Please note: use your SMTP providers TLS port (sometimes referenced as STARTTLS), as SSL port is incorrect in many cases.

Container environment variables seem to be set, but not reflected by invoice ninja. Error handling does not log any useful information.