feat: send test mail (#7968)

# Which Problems Are Solved

- Zitadel doesn't have a way to test SMTP settings either before
creating a new provider or once the SMTP provider has been created.
- Zitadel SMTP messages can be more informative for usual errors

# How the Problems Are Solved

- A new step is added to the new/update SMTP provider wizard that allows
us to test a configuration. The result is shown in a text area.
- From the table of SMTP providers you can test your settings too.
- The email address to send the email is by default the email address
for the logged in user as suggested.
- Some of the SMTP error messages have been changed to give more
information about the possible situation. For example: could not contact
with the SMTP server, check the port, firewall issues... instead of
could not dial

Here's a video showing this new option in action:


https://github.com/zitadel/zitadel/assets/30386061/50128ba1-c9fa-4481-8eec-e79a3ca69bda

# Additional Changes

Replace this example text with a concise list of additional changes that
this PR introduces, that are not directly solving the initial problem
but are related.
For example:
- The docs explicitly describe that the property XY is mandatory
- Adds missing translations for validations.

# Additional Context

- Closes #4504
This commit is contained in:
Miguel Cabrerizo
2024-06-20 21:51:42 +02:00
committed by GitHub
parent 00b5e55565
commit 3635320ce8
51 changed files with 1362 additions and 46 deletions

View File

@@ -506,6 +506,40 @@ service AdminService {
};
}
rpc TestSMTPConfigById(TestSMTPConfigByIdRequest) returns (TestSMTPConfigByIdResponse) {
option (google.api.http) = {
post: "/smtp/{id}/_test";
body: "*"
};
option (zitadel.v1.auth_option) = {
permission: "iam.write";
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "SMTP Provider";
summary: "Test SMTP Provider ";
description: "Test an SMTP provider identified by its ID. After testing the provider, the users will receive information about the test results."
};
}
rpc TestSMTPConfig(TestSMTPConfigRequest) returns (TestSMTPConfigResponse) {
option (google.api.http) = {
post: "/smtp/_test";
body: "*"
};
option (zitadel.v1.auth_option) = {
permission: "iam.write";
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "SMTP Provider";
summary: "Test SMTP Provider";
description: "Test an SMTP provider. After testing the provider, the users will receive information about the test results."
};
}
rpc ListSMTPConfigs(ListSMTPConfigsRequest) returns (ListSMTPConfigsResponse) {
option (google.api.http) = {
post: "/smtp/_search"
@@ -4257,6 +4291,82 @@ message RemoveSMTPConfigResponse {
zitadel.v1.ObjectDetails details = 1;
}
message TestSMTPConfigByIdRequest {
string id = 1 [(validate.rules).string = {min_len: 1, max_len: 100}];
string receiver_address = 2 [
(validate.rules).string = {min_len: 1, max_len: 200, email: true},
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"noreply@m.zitadel.cloud\"";
min_length: 1;
max_length: 200;
}
];
}
// This is an empty response
message TestSMTPConfigByIdResponse {}
message TestSMTPConfigRequest {
string sender_address = 1 [
(validate.rules).string = {min_len: 1, max_len: 200},
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"noreply@m.zitadel.cloud\"";
min_length: 1;
max_length: 200;
}
];
string sender_name = 2 [
(validate.rules).string = {min_len: 1, max_len: 200},
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"ZITADEL\"";
min_length: 1;
max_length: 200;
}
];
bool tls = 3;
string host = 4 [
(validate.rules).string = {min_len: 1, max_len: 500},
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"smtp.postmarkapp.com:587\"";
description: "Make sure to include the port.";
min_length: 1;
max_length: 500;
}
];
string user = 5 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"197f0117-529e-443d-bf6c-0292dd9a02b7\"";
}
];
string password = 6 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"this-is-my-password\"";
}
];
string receiver_address = 7 [
(validate.rules).string = {min_len: 1, max_len: 200, email: true},
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
example: "\"noreply@m.zitadel.cloud\"";
min_length: 1;
max_length: 200;
}
];
string id = 8 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "Zitadel SMTP provider id in case you are not sending the password and want to reuse the stored password";
example: "\"267191369515139464\"";
}
];
}
// This is an empty response
message TestSMTPConfigResponse {}
message ListSMSProvidersRequest {
//list limitations and ordering
zitadel.v1.ListQuery query = 1;