# Send email from Actions

**URL:** <https://community.auth0.com/t/send-email-from-actions/105756>\
**Category:** Get Help\
**Tags:** emails, management-api\
**Created:** [April 28, 2023, 3:39pm UTC](https://community.auth0.com/t/send-email-from-actions/105756 "2023-04-28T15:39:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeanbaptiste.marie](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jeanbaptiste.marie](https://community.auth0.com/u/jeanbaptiste.marie)\
**Post date:** [April 28, 2023, 3:39pm UTC](https://community.auth0.com/t/send-email-from-actions/105756/1 "2023-04-28T15:39:20Z")

</div>

Hello,

How can I send email using an auth0 email Template or trigger an email to be sent from an Action?

My goal is to send an email to the user when he logins if he has not changed his password for a given time. Any other idea of the best way to manage that?

Thanks in advance for your help

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [April 28, 2023, 5:43pm UTC](https://community.auth0.com/t/send-email-from-actions/105756/3 "2023-04-28T17:43:36Z")

</div>

Hi @jeanbaptiste.marie,

Welcome to the Auth0 Community!

I understand that you are trying to send a password reset email to a user whenever they log in and have not changed their password for a given time.

For this, I recommend using a Post-Login Action with the Authentication API, specifically calling the [`POST /dbconnections/change_password` endpoint](https://auth0.com/docs/api/authentication#change-password).

I have written a code snippet below to make an Axios request to the Change Password endpoint. From here, you will need to write the code to compare the user’s last password change to a given time, and if it satisfies, you can call the `sendPasswordResetEmail()` function.

```auto
exports.onExecutePostLogin = async (event, api) => {
  var axios = require("axios").default;

  const sendPasswordResetEmail = () => {
    var options = {
      method: 'POST',
      url: 'https://YOUR_DOMAIN}/dbconnections/change_password',
      headers: {'content-type': 'application/json'},
      data: {
        client_id: 'event.client.client_id',
        email: 'event.user.email',
        connection: 'event.connection.name'
        
      }
    };
    try{
    axios.request(options).then(function (response) {
      console.log("Response: ",response.data);
    })
    }catch(error){
      console.error(error)
    }
  }
  /*
  Check if the user has not changed their password for a given time.
  If this is true, call the sendPasswordResetEmail() function.
 */
}

```

Please let me know how this goes for you.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![jeanbaptiste.marie](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jeanbaptiste.marie](https://community.auth0.com/u/jeanbaptiste.marie)\
**Post date:** [May 2, 2023, 6:56am UTC](https://community.auth0.com/t/send-email-from-actions/105756/4 "2023-05-02T06:56:34Z")

</div>

Hi @rueben.tiow ,

Thanks a lot for your smart answer, I think that is exactly what I need. I will try it asap.

Regards,

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [May 16, 2023, 6:57am UTC](https://community.auth0.com/t/send-email-from-actions/105756/5 "2023-05-16T06:57:06Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
