I created a Test App to play around with sending emails from a react-native app and I keep getting this “TypeError: Cannot read property ‘mail’ of null, js engine: hermes” Error. My code is very minimal and all I am trying to do is open the devices default mail application with a very basic email. I am using expo as well and I am running the app on my Iphone 13 via expo.
Here is the code:
import { Alert, Text, View, Button } from "react-native";
import Mailer from "react-native-mail";
// npm install react-native-mail --save
function sendEmail() {
console.log(content)
Mailer.mail(
{
subject: "Test",
recipients: ["[email protected]"], // replace with your email
body: ' Account Id: #123123',
isHTML: true,
},
(error, event) => {
Alert.alert(
error,
event,
[
{ text: 'Ok', onPress: () => console.log('OK: Email Error Response') },
{ text: 'Cancel', onPress: () => console.log('CANCEL: Email Error Response') }
],
{ cancelable: true }
)
});
}
export default function Index() {
return (
<View
style={{
flex: 1,
justifyContent: "center",
alignItems: "center",
}}
>
<Text>I hope this works</Text>
<Button
onPress={sendEmail}
title="Email Me"
color="#841584"
/>
</View>
);
}
I tried removing all of the contents down to just the subject and that did not work. copliot and chatgpt were no help either.
Koen Schoffner is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1