使用React Native iOS发送电子邮件 [英] Send Email using React Native iOS
问题描述
我需要能够使用反应本身发送电子邮件。
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)
我已经查找了似乎能够做到这一点的各种模块,但是迄今没有人使用反应本身 https://nodemailer.com )
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)
需要的是iOS弹出的标准电子邮件提示(如本模块中的 https:// www .npmjs.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.
推荐答案
不幸的是,iOS在默认情况下不支持邮件。
Unfortunately, iOS doesn't support to mail in background by default.
您可以做什么 - 是做出XHR请求到您的后台,您需要一个数据,并在服务器上处理邮件程序。
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:
How to send an email to a receipent in background in iOS5?
UPD:您还可以尝试使用 iphone smtp客户端库。这意味着您需要创建一个将SMTP功能与JS部分进行桥接的反应原生模块。但是在这里,您需要在代码中存储一些私有凭据,使其易于进行逆向工程。
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.
这篇关于使用React Native iOS发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!