Hello Guys, I want to change the templating of my...
# ory-selfhosting
f
Hello Guys, I want to change the templating of my mails , we are using ory - kratos (self hosted) i have been following the documentation : https://www.ory.sh/docs/kratos/concepts/email-sms#sender-address-and-template-customization our kratos.yml courier block looks like this
Copy code
courier:
  smtp:
    connection_uri: <smtps://test:test@mailslurper:1025/?skip_ssl_verify=true>

  # template_override_path: /courier/template/templates

  templates:
    # we can specify here
    recovery:
      valid:
        email:
          body:
            # plaintext and html are required when overriding the body
            html: <file://courier/template/templates/recovery/valid/email.body.gotmpl>
            plaintext: file:///courier/template/templates/recovery/valid/email.body.gotmpl
          # optional
          subject: file:///courier/template/templates/recovery/valid/email.subject.gotmpl
      # we can also omit the `invalid` field here if you wish to use the default built-in templates
      # or template_override_path
      # invalid:
Kindly someone provide some assistance CC: @magnificent-energy-493 , @worried-kitchen-94392
b
What kind of error message are you getting?
f
@bulky-architect-22083
Copy code
courier: map[smtp:map[connection_uri:<smtps://test:test@mailslurper:1025/?skip_ssl_verify=true> from_address:no-reply@ory.kratos.sh] templates:map[recovery:map[valid:map[email:map[body:map[html:<file://courier/template/templates/recovery/valid/email.body.gotmpl> plaintext:file:///courier/template/templates/recovery/valid/email.body.gotmpl] subject:file:///courier/template/templates/recovery/valid/email.subject.gotmpl]]]]]
kratos_1          |          ^-- additionalProperties "templates" not allowed
kratos_1          |
kratos_1          | time=2022-07-04T12:48:00Z level=fatal msg=The services failed to start because the configuration is invalid. Check the output above for more details. func=<http://github.com/ory/x/viperx.WatchAndValidateViper|github.com/ory/x/viperx.WatchAndValidateViper> file=/go/pkg/mod/github.com/ory/x@v0.0.165/viperx/watch_and_validate_viper.go:22 audience=application service_name=kratos service_version=
we are using version v0.5.5-alpha.1
s
the directory structure would be used to distinguish body/subject/... and MIME types
f
thanks @steep-lamp-91158, will look into it
s
I'd recommend to update kratos though 😅
f
Sure @steep-lamp-91158, we will consider it upgrading😅
@steep-lamp-91158 , After the changes it gives the following error
Copy code
kratos_1          |     /usr/local/go/src/runtime/asm_amd64.s:1374] http_request=map[headers:map[accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 accept-encoding:gzip, deflate accept-language:en-IN,en-GB;q=0.9,en-US;q=0.8,en;q=0.7 cache-control:max-age=0 cookie:_delighted_web={%22zzdZluPXuBRu7vCL%22:{%22_delighted_fst%22:{%22t%22:%221655816800553%22}%2C%22_delighted_lst%22:{%22t%22:%221655888091104%22%2C%22m%22:{%22token%22:%22wJqE6COX5zlDd7puMNexeoK6%22}}%2C%22_delighted_lrt%22:{%22t%22:%221655888093796%22%2C%22m%22:{%22token%22:%22wJqE6COX5zlDd7puMNexeoK6%22}}}}; _hp2_id.1370490571=%7B%22userId%22%3A%22554847872887190%22%2C%22pageviewId%22%3A%228841645092379934%22%2C%22sessionId%22%3A%223388889685116007%22%2C%22identity%22%3Anull%2C%22trackerVersion%22%3A%224.0%22%7D; csrf_token=4Jns159Sh2Fi2caIvSbCr06ivkPtTpOGkBfxyahMnPE=; mp_52e5e0805583e8a410f1ed50d8e0c049_mixpanel=%7B%22distinct_id%22%3A%20%22181678255e88d3-0a65094923fd0f-613f5653-100200-181678255e9752%22%2C%22%24device_id%22%3A%20%22181678255e88d3-0a65094923fd0f-613f5653-100200-181678255e9752%22%2C%22%24initial_referrer%22%3A%20%22http%3A%2F%2F127.0.0.1%3A8080%2F%22%2C%22%24initial_referring_domain%22%3A%20%22127.0.0.1%3A8080%22%7D origin:<http://127.0.0.1:8080> referer:<http://127.0.0.1:8080/> user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36] host:127.0.0.1:4433 method:POST path:/self-service/recovery/methods/link query:flow=fd4ef5d4-0643-4b31-8769-6d0f87655196 remote:172.18.0.1:45394 scheme:http] recovery_flow=&{fd4ef5d4-0643-4b31-8769-6d0f87655196 browser 2022-07-04 15:37:10.938441 +0000 UTC 2022-07-04 14:37:10.938441 +0000 UTC <http://127.0.0.1:4433/self-service/recovery/browser>  [] map[link:0xc000227ce0] [] choose_method 73C9o3Su/IviOqsWJvsemPHfsJ+7+KNvl1AmYt/AFiwP6VF06/x76oDjbZ6b3dw3v30O3Fa2MOkHR9erd4yK3Q== 2022-07-04 14:37:10.938673 +0000 UTC 2022-07-04 14:37:10.938682 +0000 UTC {00000000-0000-0000-0000-000000000000 false}} service_name=ORY Kratos service_version=v0.5.5-alpha.1
kratos_1          | time=2022-07-04T14:37:13Z level=error msg=An error occurred and is being forwarded to the error user interface. func=<http://github.com/ory/kratos/selfservice/errorx.(*Manager).Create|github.com/ory/kratos/selfservice/errorx.(*Manager).Create> file=/home/ory/selfservice/errorx/manager.go:44 audience=application error=map[message:open email-templates/recovery/valid/email.body.gotmpl: no such file or directory trace:
@steep-lamp-91158, kratos.yml looks like this :
courier:
smtp: connection_uri: smtps://test:test@mailslurper:1025/?skip_ssl_verify=true template_override_path: email-templates
s
did you create the necessary files using the directory structure, in this case
email-templates/recovery/valid/email.body.gotmpl
?
f
yes i have created @steep-lamp-91158 PFA screenshot
s
hm can't tell you more than the error message unfortunately... it somehow does not find the file
is the directory also mounted properly in your docker compose?
or whatever system you are using to run kratos?
f
@steep-lamp-91158, how do i check that the directory is properly mounted in docker ??
w
If you are using our helm charts I'd suggest checking for a version that was running with that version of kratos
f
@worried-kitchen-94392 , I do not use helm charts
w
Docker or k8s?
f
i am using docker @worried-kitchen-94392
w
Then you would need to mount the files to the docker env, you can check out the QuickStart examples in kratos repo