Search code examples
reactjsreact-nativeemailexpo

how send a email in react native with emailjs


I created a react native app with expo, I have emailjs. this option are enabled

enter image description here

but I have the next error when I send the form.

FAILED... {"status": 403, "text": "API calls in strict mode, but no private key was passed"}

this is my code, can any help me?? where I put it and how do I pass the private key?...

import emailjs from '@emailjs/browser';

import {
  serviceID,
  templateID,
  publicKey,
  emailUserid,
  accessToken,
} from '../../utils/email-configuration';


export const emailSend = (data) => {
  let templateParams = {
    to_name: `${values.name}`,
    to_email: `${values.email}`,
    from_name: 'Juan',
    message: `${values.description}`,
  };
  console.log('ENVIADOS: ', JSON.stringify(templateParams));

  emailjs.send(serviceID, templateID, templateParams, publicKey).then(
    function (response) {
      console.log('SUCCESS!', response.status, response.text);
    },
    function (error) {
      console.log('FAILED...', error);
    }
  );
};

I try in the field of public key send a json with public and private key.

const Options = {
   publicKey: publicKey,
   accessToken: privateKey,
  };
 

emailjs.send(serviceID, templateID, templateParams, Options)

Solution

  • I had the same problem.

    Step 1

    Go to this page: https://dashboard.emailjs.com/admin/account/security

    Step 2

    On the page: https://dashboard.emailjs.com/admin/account/security, Change the API settings. Uncheck the box of use private keys: setting to change. view here.