react-native-sendgrid-template

1.1.0 • Public • Published

If this project result useful for you consider donate

ko-fi

React Native SendGrid

Is a API Wrapper for SendGrid, Usage is simple

Installation

npm install --save react-native-sendgrid

Usage

import { sendGridEmail } from 'react-native-sendgrid'
...
...
const SENDGRIDAPIKEY = "YOURAPIKEY";
const FROMEMAIL = "test@test.com";
const TOMEMAIL = "me@test.com";
const SUBJECT = "You have a new message";

export class ContactForm extends Component {
	constructor(props) {
   		super(props);
   		this.state = {name : "", email: "", phone:""};
	}

	yourSendEmailFunction(){
		
		const ContactDetails = "Contact Data: " + this.state.name + " Mail: "+ this.state.email+" Phone: "+this.state.phone
		
		const sendRequest = sendGridEmail(SENDGRIDAPIKEY, TOMEMAIL, FROMEMAIL, SUBJECT, ContactDetails )
	        sendRequest.then((response) => {
	            console.log("Success")
	        }).catch((error) =>{
	            console.log(error)
	        });
	}

}

Use HTML

By default all emails are send in "text/plain" format if you want to use html format just use this way:

const sendRequest = sendGridEmail(SENDGRIDAPIKEY, TOMEMAIL, FROMEMAIL, SUBJECT, ContactDetails, "text/html" )

admin@scriptmatico.com

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i react-native-sendgrid-template

      Weekly Downloads

      1

      Version

      1.1.0

      License

      ISC

      Unpacked Size

      4.4 kB

      Total Files

      6

      Last publish

      Collaborators

      • toyindaniyan