您需要从应用程序发送电子邮件以做出本机反应 .
使用react-native-mailcore,但它无法附加文件 . 这是我的主要任务
我怎样才能通过smtp发送包含文件的电子邮件?
我遇到了同样的问题,所以我最终创建了自己的库:react-native-smtp-mailer .
您使用您的凭据连接到smtp服务器以向收件人发送电子邮件,并能够添加html正文,附件等(ios android) . 事实上,它是ios mailcore2和android javamail主要功能的桥梁 .
希望这也能帮到别人 .
react-native-mail怎么样?
它是“iOS上的MFMailComposeViewController和Android上的Mail Intent的顶层包装器”
var Mailer = require('NativeModules').RNMail; var MailExampleApp = React.createClass({ handleHelp: function() { Mailer.mail({ subject: 'need help', recipients: ['support@example.com'], body: '', attachment: { path: '', // The absolute path of the file from which to read data. type: '', // Mime Type: jpg, png, doc, ppt, html, pdf name: '', // Optional: Custom filename for attachment } }, (error, event) => { if(error) { AlertIOS.alert('Error', 'Could not send mail. Please send a mail to support@example.com'); } }); }, render: function() { return ( <TouchableHighlight onPress={row.handleHelp} underlayColor="#f7f7f7"> <View style={styles.container}> <Image source={require('image!announcement')} style={styles.image} /> </View> </TouchableHighlight> ); } });
2 回答
我遇到了同样的问题,所以我最终创建了自己的库:react-native-smtp-mailer .
您使用您的凭据连接到smtp服务器以向收件人发送电子邮件,并能够添加html正文,附件等(ios android) . 事实上,它是ios mailcore2和android javamail主要功能的桥梁 .
希望这也能帮到别人 .
react-native-mail怎么样?
它是“iOS上的MFMailComposeViewController和Android上的Mail Intent的顶层包装器”