Send email from Actions


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

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.

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.

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: '',
        connection: ''
    axios.request(options).then(function (response) {
      console.log("Response: ",;
  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.


Hi @rueben.tiow ,

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


1 Like

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