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
EmailJS works with all modern frameworks, and React is no exception.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With