# Keycloak Test Email fails with Error " Failed to Send Email "

**URL:** <https://forum.keycloak.org/t/keycloak-test-email-fails-with-error-failed-to-send-email/15441>\
**Category:** Configuring the server\
**Tags:** authentication\
**Created:** [May 10, 2022, 4:58am UTC](https://forum.keycloak.org/t/keycloak-test-email-fails-with-error-failed-to-send-email/15441 "2022-05-10T04:58:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nisharunnisa](https://avatars.discourse-cdn.com/v4/letter/n/f6c823/32.png) [@Nisharunnisa](https://forum.keycloak.org/u/Nisharunnisa)\
**Post date:** [May 10, 2022, 4:58am UTC](https://forum.keycloak.org/t/keycloak-test-email-fails-with-error-failed-to-send-email/15441/1 "2022-05-10T04:58:16Z")

</div>

Hi Team ,

We have Installed & Configured Keycloak on different kubernetes environments for our use case. We configured AWS SES for smtp configurations. The Email option is working on one kubernetes cluster but not other .We are using same smtp credentials for both Keycloak.  
Below is the keycloak logs :  
**org.keycloak.email.EmailException: com.sun.mail.util.MailConnectException: Couldn’t connect to host, port: [email-smtp.xx-xxx-1.amazonaws.com](http://email-smtp.xx-xxx-1.amazonaws.com), 587; timeout 10000;**

![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/5/5ea7f621d5648c266078acd61db7df255054cc58.png)

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/c/cfee847b296d8f40ffcd9444b81b02f690ff8ceb.png)

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [May 10, 2022, 5:59am UTC](https://forum.keycloak.org/t/keycloak-test-email-fails-with-error-failed-to-send-email/15441/2 "2022-05-10T05:59:33Z")

</div>

Try only `StartTLS` and not `Enable SSL`

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [May 10, 2022, 6:00am UTC](https://forum.keycloak.org/t/keycloak-test-email-fails-with-error-failed-to-send-email/15441/3 "2022-05-10T06:00:48Z")

</div>

Actually, your config looks like you’ve set port 465, and your log shows 587.

If it’s a timeout, you should also check network connectivity between your server and that host/port.

---

<div class="post-metadata">

**Author:** ![Nisharunnisa](https://avatars.discourse-cdn.com/v4/letter/n/f6c823/32.png) [@Nisharunnisa](https://forum.keycloak.org/u/Nisharunnisa)\
**Post date:** [May 10, 2022, 9:16am UTC](https://forum.keycloak.org/t/keycloak-test-email-fails-with-error-failed-to-send-email/15441/4 "2022-05-10T09:16:01Z")

</div>

Hi @xgp

Thank you for the reply , Tried without SSL also same error

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/2/29bf396d8fccdb35ffeac285c4fed3123aa1c65a.png)

---

<div class="post-metadata">

**Author:** ![toytanik](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@toytanik](https://forum.keycloak.org/u/toytanik)\
**Post date:** [December 12, 2023, 3:51pm UTC](https://forum.keycloak.org/t/keycloak-test-email-fails-with-error-failed-to-send-email/15441/5 "2023-12-12T15:51:00Z")

</div>

So what happened, did it fix ?

---

<div class="post-metadata">

**Author:** ![ejbest66](https://avatars.discourse-cdn.com/v4/letter/e/ecae2f/32.png) [@ejbest66](https://forum.keycloak.org/u/ejbest66)\
**Post date:** [June 12, 2024, 1:37pm UTC](https://forum.keycloak.org/t/keycloak-test-email-fails-with-error-failed-to-send-email/15441/6 "2024-06-12T13:37:26Z")

</div>

Very interested if this was resolved?

---

<div class="post-metadata">

**Author:** ![gmolaire](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/gmolaire/32/10287_2.png) [@gmolaire](https://forum.keycloak.org/u/gmolaire)\
**Post date:** [June 12, 2024, 2:23pm UTC](https://forum.keycloak.org/t/keycloak-test-email-fails-with-error-failed-to-send-email/15441/7 "2024-06-12T14:23:54Z")

</div>

This is most likely a network configuration issue. If anyone else is having the same, verify:

- If you have network policies in your k8s namespaces, verify if they are allowing egress to SES as well
- If you are using a service mesh, make sure you allow egress through that port and the correct endpoint
- If your security group for the cluster nodes is allowing egress through your SMTP port
- If your subnet if not blocking the connection through outbound ACL rules
- If you are using a VPC endpoint/interface that you are allowing traffic to go through the right endpoint and port as well

With those in mind, you should be able to communicate with SES without any trouble.

---

<div class="post-metadata">

**Author:** ![prifulnath](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/prifulnath/32/10323_2.png) [@prifulnath](https://forum.keycloak.org/u/prifulnath)\
**Post date:** [August 30, 2024, 5:34am UTC](https://forum.keycloak.org/t/keycloak-test-email-fails-with-error-failed-to-send-email/15441/8 "2024-08-30T05:34:59Z")

</div>

Was it resolved? I am also facing the similar issue. When using some port, it is showing couldn’t connect to host and when using some other port it is showing 503 Authentication required (I am trying to use role-based permission without username and password)
