4

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)

3 Answers 3

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
1

You should pass a private key in the same way you pass public key, service template and service id:

var data = {
    service_id: 'YOUR_SERVICE_ID',
    template_id: 'YOUR_TEMPLATE_ID',
    user_id: 'YOUR_PUBLIC_KEY',
    accessToken: 'YOUR_ACCESS_TOKEN',
    template_params: {
        'username': 'James',
        'g-recaptcha-response': '03AHJ_ASjnLA214KSNKFJAK12sfKASfehbmfd...'
    }
};

Documentation: https://www.emailjs.com/docs/rest-api/send/

Here's an article I wrote explaining how to setup sensitive EmailJS data in Vite+React app deployed on Vercel.

Comments

0

You have to provide the Private Key as an argument to the send() function. In SDK v4+, the fourth parameter is used to pass a set of options.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.