Suggestion:
There are multiple ways to achieve this and one way is to disable Gmail by doing the following:
- Create an organizational unit on admin.google.com on Directory > Organizational units > Create organizational unit.
- Go to Users > Click on More Options, and then choose “Change organizational unit, and choose the newly created Organizational unit.
- Go to Apps > Google Workspace > Gmail, and click on Service Status, and then choose the newly created Organizational unit on the left side panel, and choose Service Status OFF.
Another option, if you don’t want to disable access to the Gmail Service is to create a custom routing feature. This can be achieved by doing the following:
- Follow Steps 1 and 2 on my first suggestion.
- Go to Apps > Google Workspace > Gmail > Routing.
- Under the Routing option, click on Configure.
- Choose Email messages to affect, and click on Outbound & Internal Sending.
- Under “For the above types of messages, do the following”, choose “Reject Message” and set your own customized rejection notice message and then hit “Save”.
If you would like to implement the use of API to manage your Google Workspace directories, you can check this reference instead.
References:
https://support.google.com/a/answer/6297084
https://support.google.com/a/answer/182442
https://developers.google.com/admin-sdk/directory/v1/guides