4

I need to be able to send emails using react native.

The user inputs text data into a form and presses the submit button, the text should then be copied into a new email and sent to an address where i can view the data. It will always be sent to the same address.

So basically what i need is sending emails from within the app, while sender and recipient address stay the same for every user. (Not choosable by the user or anything)

I have looked up various modules which seem to be able to do that, but none has worked with react native so far (i.e. https://nodemailer.com)

What i don't need is the standard email prompt of iOS popping up (As in this module https://www.npmjs.com/package/react-native-communications). It should always be done in the background, without the user even knowing an email has been sent, just getting a confirm that the data has been submitted.

2
  • This seems more like a Swift or Objective-C issue. stackoverflow.com/questions/29034099/…, and if it is even possible to do it the way you want, you'd have to write a module and expose it to React Native moduscreate.com/swift-modules-for-react-native. Commented Mar 26, 2016 at 11:58
  • Alright thank you, it would be really convenient if this would work in react alone, but if it's impossible i'll have to go find another way to do it (probably by implementing a custom Swift module) Commented Mar 26, 2016 at 12:06

2 Answers 2

2

Unfortunately, iOS doesn't support to mail in background by default.

What you can do - is to make an XHR request to your backend with a data you need and process a mailing procedure on the server.

Probably you'll find more handy information here:

UPD: You can also try to use iphone smtp client library directly. It means that you need to create a react-native module that will bridge SMTP functionality to the JS part. But here you'll need to store some private credentials in the code which makes them vulnerable to reverse-engineering.

Sign up to request clarification or add additional context in comments.

Comments

1

I've just created an npm package that allows send user to another email app.

https://github.com/ErickMaeda/react-native-email-action

It's easy to install, and you don't need any native code to link.

Install:

npm install --save react-native-email-action

Usage

import { sendEmail } from 'react-native-email-action';

const options = {
  to: "[email protected]", 
  subject: "Very important!", 
  body: "Verify your email fast!"
};
sendMail(options);

Important

After iOS 9+, you need to add this information keys on Info.plist

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>message</string>
  <string>ms-outlook</string>
  <string>googlegmail</string>
</array>    

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.