<@U04UQ68083H> after upgrading ory kratos to 1.1 f...
# ory-copilot
m
@chilly-king-10285 after upgrading ory kratos to 1.1 from 1.0 our kratos instance now tries to send verification emails using smtp server instead of making an http request to our local service that handles sending out emails. How do we keep using the http method instead of smtp
c
A message from kapa.ai
To configure Ory Kratos to send verification emails using an HTTP request instead of an SMTP server, you need to set the
delivery_strategy
configuration key to
http
and provide the necessary details for your HTTP server. Here are the steps to do this: 1. Download the Ory Identities config from your project and save it to a file using the Ory CLI:
Copy code
bash ## List all available projects   ory list projects      ## Get config   ory get identity-config {project-id} --format yaml > identity-config.yaml
2. Add the configuration for your custom HTTP server to the
config.yml
file:
Copy code
yaml courier:    delivery_strategy: http    http:    request_config:    url: <https://mail-sender.example.com>    method: POST    body: base64://... # See below for the default payload and available variables    headers:    Content-Type: application/json    auth: # leave out, if your server doesn't require authentication, but note that we don't recommend that    type: basic_auth # or api_key    config:    user: my-username    password: my-password    # if you want to use an API key (type: api_key), use the following config instead:    # name: my-api-name    # value: my-api-key-value    # in: header # or cookie
3. Update the Ory Identities configuration using the file you worked with:
Copy code
bash ory update identity-config {project-id} --file updated_config.yaml
Please note that the payload of the HTTP request is a JSON object that's generated using a Jsonnet template. You can customize the payload according to your needs. The Ory Console doesn't support configuring this yet, so you need to use the Ory CLI. For more details, please refer to the [Ory documentation](https://www.ory.sh/docs/kratos/emails-sms/sending-emails-smtp#send-emails-using-an-http-server).
m
@chilly-king-10285 can we remove the smpt label from the configuration ?
c
A message from kapa.ai
Yes, you can remove the SMTP configuration from your Ory Kratos configuration file if you are not using it. If you are using HTTP for email delivery, the SMTP configuration is not necessary. Here is an example of how your configuration might look after removing the SMTP settings:
Copy code
yaml courier:    delivery_strategy: http    http:    request_config:    url: <https://mail-sender.example.com>    method: POST    body: base64://... # See below for the default payload and available variables    headers:    Content-Type: application/json    auth: # leave out, if your server doesn't require authentication, but note that we don't recommend that    type: basic_auth # or api_key    config:    user: my-username    password: my-password    # if you want to use an API key (type: api_key), use the following config instead:    # name: my-api-name    # value: my-api-key-value    # in: header # or cookie
Remember to replace the placeholders with your actual values. After making these changes, you can update the Ory Identities configuration using the Ory CLI:
Copy code
bash ory update identity-config {{project-id}} --file updated_config.yaml
For more details, please refer to the [Ory documentation](https://www.ory.sh/docs/kratos/self-hosted/email-http).
m
@chilly-king-10285 I get the following error message when i remove the smpt label The configuration contains values or keys which are invalid: courier.smtp.connection_uri: <nil> ^-- one or more required properties are missing If i keep it then smpt seems to take precedence over the http method
c
A message from kapa.ai
It seems like Ory Kratos requires the
courier.smtp.connection_uri
field in the configuration, even if you're not using SMTP for email delivery. However, you can work around this by providing a dummy SMTP URI. This way, the configuration validation will pass, but since you've set the
delivery_strategy
to
http
, Kratos will still use the HTTP method for sending emails. Here's an example:
Copy code
yaml courier:    delivery_strategy: http    smtp:   connection_uri: <smtp://dummy:dummy@dummy:587>  http:    request_config:    url: <https://mail-sender.example.com>    method: POST    body: base64://... # See below for the default payload and available variables    headers:    Content-Type: application/json    auth: # leave out, if your server doesn't require authentication, but note that we don't recommend that    type: basic_auth # or api_key    config:    user: my-username    password: my-password    # if you want to use an API key (type: api_key), use the following config instead:    # name: my-api-name    # value: my-api-key-value    # in: header # or cookie
Remember to replace the placeholders with your actual values. After making these changes, you can update the Ory Identities configuration using the Ory CLI:
Copy code
bash ory update identity-config {{project-id}} --file updated_config.yaml
For more details, please refer to the [Ory documentation](https://www.ory.sh/docs/kratos/self-hosted/email-http).
m
@chilly-king-10285 this is our current config
Copy code
courier:
      delivery_strategy: http
      http:
        request_config:
          url: <http://emails:8080/api>
          method: POST
          body: <base64://__EMAIL_JSONNET__>
          headers:
            Content-Type: application/json
      smtp: # Kratos bug, see: <https://github.com/ory/kratos/issues/3559>
        connection_uri: <smtps://foo:bar@my-mailserver:1234/?skip_ssl_verify=false>
after we updated our self-hosted kratos instance from 1.0 to 1.1 the kratos internals always pick email as channels instead of http. We don't want to use the smpt or email channel but rather the http sending method
c
A message from kapa.ai
Your configuration seems correct for using HTTP as the delivery strategy. However, if Ory Kratos is still picking SMTP as the delivery method, it might be due to a bug or an issue with the upgrade process. Here are a few things you can try: 1. Check for Errors in the Configuration: Make sure there are no errors in your configuration file. The error message you're seeing might be due to an issue with the configuration file. 2. Reapply the Configuration: Try reapplying the configuration using the Ory CLI. This can sometimes resolve issues that occur due to caching or stale configuration data.
Copy code
bash ory update identity-config {{project-id}} --file updated_config.yaml
3. Contact Ory Support: If you're still having issues, it might be best to reach out to Ory support or open an issue on the Ory Kratos GitHub page. They might be able to provide more specific guidance based on your setup. Remember to replace
{{project-id}}
and
updated_config.yaml
with your actual project ID and the path to your configuration file. For more details, please refer to the [Ory documentation](https://www.ory.sh/docs/kratos/self-hosted/email-http).