Home > Mobile >  Is it possible to send Server less email in react native?
Is it possible to send Server less email in react native?

Time:08-12

Hi there I am trying to send server less email through react native I have researched about it and came to know that it is possible to send in Reactjs using EMAILJS but in react-native I have not found any solution yet. Can anyone help in this scenario ? or guide me about any available library. Thanks in advance

CodePudding user response:

EmailJS supports REST APIs. You can directly call them from your React Native app without any 3rd party library.

const sendMail = async () => {
  const url = 'https://api.emailjs.com/api/v1.0/email/send';

  const data = {
    service_id: 'YOUR_SERVICE_ID',
    // other data .....
  };
  
  const params = {
    method: 'POST',
    body: JSON.stringify(data),
    headers: {
      'Content-Type': 'application/json'
    }
  };
  
  try {
    await fetch(url, params);
    console.log('Your mail is sent!');
  } catch (error) {
    console.error(error);
  }
};
  • Related