Unable to send email using azure communication services

SabariDev 45 Reputation points
2025-05-24T03:02:55.82+00:00

"Try Email" option on azure console works well - I was able to send a test email through my verified custom domain, and then I had tried to reuse given sample java code in my springboot application and I have putvalid connection string. Yet, I get the following error : Status code 401, "{"error":{"code":"Denied","message":"Denied by the resource provider."}}"

Azure Communication Services
0 comments No comments

Answer accepted by question author
Anonymous
2025-05-26T05:23:39.2766667+00:00

Hi SabariDev,

Although the Try Email feature works in the Azure portal with your verified custom domain, the 401 Denied by the resource provider error in your Spring Boot app using the Java sample suggests a problem with the ACS Email SDK setup, most likely due to an incorrect or expired connection string, the email service not being enabled on your ACS resource, a misconfigured verified domain, or missing permissions on the email access key.

  • Make sure you're using the correct Email Access Key connection string, not one for chat or voice.

Go to your Azure Communication Services resource -> Click on Keys -> Copy the Primary Connection String under the Email section.

The format should be like this endpoint=https://<your-resource-name>.communication.azure.com/;accesskey=<your-key>.

  • Please check that Email is enabled for your ACS resource. 

Go to your ACS resource in the Azure portal -> under Email (Preview), make sure the feature is enabled and configured -> confirm your custom domain is set as the default sender domain.

  • Check that your custom domain is verified, connected, and active with the correct DNS records (SPF, DKIM, CNAME) by going to your ACS resource, selecting Email → Domains, and confirming the status is Connected and Verified, and ensure the From email in your code exactly matches your verified domain.
  • Please check Resource Configuration
// Ensure you're using the correct endpoint format
EmailClient emailClient = new EmailClientBuilder()
    .connectionString("your-email-specific-connection-string")
    .buildClient();

Send an email using Azure Communication Services

Add custom verified email domains

Please accept as "Yes" if the answer provided is useful, so that you can help others in the community looking for remediation for similar issues.

Let me know if you have any further Queries.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.