react-native-sendgrid-template
v1.1.0
Published
Is a API Wrapper to send emails using SendGrid
Downloads
1
Readme
If this project result useful for you consider donate
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 = "[email protected]";
const TOMEMAIL = "[email protected]";
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" )