Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to send email directly in React Native App

I am progromming about function: send Email to gmail Address directly from React native App. I searched on Internet and try library: https://github.com/anarchicknight/react-native-communications, https://github.com/chirag04/react-native-mail. Howerver, they only show me view of Gmail App which I installed in my device. I want react native app will send directly to Address Email. My device I tested run on Android Platform. Thank you so much

like image 866
vannguyen Avatar asked Jun 14 '17 05:06

vannguyen


People also ask

Does EmailJS work with react-native?

EmailJS works with all modern frameworks, and React is no exception.

How do I send an email with an attachment in react?

import React, { useRef } from 'react'; import emailjs from '@emailjs/browser'; export const ContactUs = () => { const form = useRef(); const addFile = () => { inputFile. current. click(); }; const sendEmail = (e) => { e. preventDefault(); emailjs.

How do I send an email from firebase in react-native?

import * as functions from "firebase-functions"; import admin from "firebase-admin"; import nodemailer from "nodemailer"; const { email, password } = functions. config(). gmail; const mailTransport = nodemailer. createTransport( `smtps://${email}:${password}@smtp.gmail.com` ); export default functions.


2 Answers

You need an email server or an email services to send an email, there is no way you can send an email directly from the client side.

There are several of them in the internet, you can try: MailGun or SendPulse, they got some good free tiers.

Your job is just calling a simple POST method from your app to their APIs.

like image 144
Goon Nguyen Avatar answered Oct 07 '22 04:10

Goon Nguyen


I have tried, and so far succeeded in testing with iOS, with react-native-email ("npm install react-native-email").

There is a bit of fluffing around when sending the first email as you have to "login" to your email account. But otherwise, test emails are going through fine.

Also, SendPulse is a bulk newsletter service, not for individual emails.

One annoying caveat: it won't work in your emulator. It will return a URL error when you click the send button. But it works fine on a real device. I'm using Expo (and who wouldn't) and it works fine on my iPhone.

Complete code for testing purposes here: https://github.com/tiaanduplessis/react-native-email

like image 35
Kelvin Aitken Avatar answered Oct 07 '22 04:10

Kelvin Aitken