chirag04 / react-native-mail Goto Github PK
View Code? Open in Web Editor NEWA wrapper on top of MFMailComposeViewController from iOS and Mail Intent on android
License: MIT License
A wrapper on top of MFMailComposeViewController from iOS and Mail Intent on android
License: MIT License
@chirag04, can you update npm to v1.1.0. It's currently at 1.0.0.
Thanks!
Could we possibly update the npm version?
There seems to be a recent commit on master that has fixed the error:
RCTLog.js:48 Module RNMail requires main queue setup since it overrides
initbut doesn't implement
requiresMainQueueSetup. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.`
but it hasn't been tagged with 3.0.5
or whatever.
I almost missed this module because I was searching for react-native email on Google, Github, and React Parts. I ended up bumping into it via http://www.reactnative.com/keep-your-contacts-closer-with-react-native/
If you would add the keyword Email to the repo desc and/or the Readme it might help rank. I like this module because it's not a kitchen sink like 'react-native-communications' is.
Thanks! ๐ป
When i call the function it shows
Unsupported Action
This action is not currently supported
Can anybody help me ! How can i fix it ?
Thanks in advance
After I did Mailer.mail({..., I got from the console that Cannot read property 'mail' of undefined.
I have defined var Mailer = require('NativeModules').RNMail; at the top the file.
Why is that happening? How can I fix it?
By the way, in your tutorial you say Add the file "libRNMail.a" to Build Phases > Link... However, I couldn't find that file. I found the one being shown in the picture and is "libRNOverlay,a". Is that what you meant? Thanks!
Can not add libRNMail.a to Link Binary with Libraries, it's marked as red and stay in Recovered Reference.
code in android/settings.gradle
rootProject.name = 'BOSSCompany'
include ':react-native-svg'
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')
include ':react-native-sockets'
project(':react-native-sockets').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sockets/android')
include ':react-native-mail'
project(':react-native-mail').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-mail/android')
include ':SocketIo'
project(':SocketIo').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-socketio/android')
include ':react-native-background-job'
project(':react-native-background-job').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-background-job/android')
include ':react-native-fs'
project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android')
include ':react-native-file-provider'
project(':react-native-file-provider').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-file-provider/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-billing'
project(':react-native-billing').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-billing/android')
include ':react-native-orientation'
project(':react-native-orientation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-orientation/android')
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
include ':react-native-image-picker'
project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android')
include ':react-native-html-to-pdf'
project(':react-native-html-to-pdf').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-html-to-pdf/android')
include ':react-native-fetch-blob'
project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fetch-blob/android')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':RNMail', ':app'
project(':RNMail').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-mail/android')
include ':app'
android/app/build.gradle
dependencies {
compile project(':react-native-svg')
compile project(':react-native-sockets')
compile project(':react-native-mail')
compile project(':SocketIo')
compile project(':react-native-background-job')
compile project(':react-native-fs')
compile project(':react-native-file-provider')
compile project(':RNMail')
compile project(':react-native-vector-icons')
compile project(':react-native-billing')
compile project(':react-native-orientation')
compile project(':react-native-maps')
compile project(':react-native-image-picker')
compile project(':react-native-html-to-pdf')
compile project(':react-native-fetch-blob')
compile project(':react-native-device-info')
compile(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile 'com.google.android.gms:play-services-gcm:+'
compile 'com.google.android.gms:play-services-base:+'
compile 'com.google.android.gms:play-services-maps:+'
}
yarn add react-native-mail
react-native link
Unhandled JS Exception: Mailer.mail is not a function. (In 'Mailer.mail', 'Mailer.mail' is undefined)
Environment:
OS: macOS Sierra 10.12.6
Node: 8.9.1
Yarn: 1.3.2
npm: 5.5.1
Watchman: 4.7.0
Xcode: Xcode 8.3.2 Build version 8E2002
Android Studio: 2.3 AI-162.4069837
Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: 0.51.0 => 0.51.0
Hi, I am getting the following error on iOS devices and in iOS simulator
Here is the piece of code I am using. It worked fine til recent. was there any version produced with any changes for attachments?
_handleEmail = () => {
Mailer.mail({
subject: '',
recipients: ['[email protected]'],
ccRecipients: [''],
bccRecipients: [''],
body: '',
isHTML: true,
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) => {
Alert.alert(
error,
event,
[
{text: 'Ok', onPress: () => console.log('OK: Email Error Response')},
{text: 'Cancel', onPress: () => console.log('CANCEL: Email Error Response')}
],
{ cancelable: true }
);
});
}
Any ideas to solve this?
react-native 0.49.2 generates a warning:
Module RNMail requires main queue setup since it overrides
init
but doesn't implement `requiresMainQueueSetup. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
When running on a simulator I get a callback saying the service is not available.
On a device, the service is available and the mail is sent successfully but the callback is not called at all. Is this expected? The readme says:
On android callback will only have error(if any) as the argument. event is not available on android.
To me this means the callback should get fired on success, but the error argument will be false or undefined.
I need to do some bookkeeping after the mail is sent so need to know ...
Currently we can only specify one attachment per email. It would be very useful to have the ability to add more than one attachment in the same email.
Currently, emails cannot be attached on android unless the attachment is on an external storage. This can be resolved by:
import android.webkit.URLUtil;
if (attachment.hasKey("path") && !attachment.isNull("path")) {
String path = attachment.getString("path");
Uri p;
// Check for valid URI
if (URLUtil.isValidUrl(path)) {
p = Uri.parse(path);
}
// Else this is an absolute file path
else {
File file = new File(path);
p = Uri.fromFile(file);
}
i.putExtra(Intent.EXTRA_STREAM, p);
}
I have made these changes in my fork of this repo, and I have also incorporated the pull request
#42 by rusel1989
However, I can't make a pull request because I am using react-native 0.39, and the latest repo is for react-native 0.40.
If anyone needs this functionality, they are welcome to look at my fork
https://github.com/ujwal-setlur/react-native-mail
-ujwal
I know this issue has been answered, but I have a user who's getting this, and he swears that he has the mail
app installed and has an account set up. Is there any other known condition that can cause this? I would check his device to verify, but he's on the other side of the planet from me.
When run under the simulator like this
I'm using react native 0.51 and I tried mail on both Android and IOS. However, none of them worked. On IOS an error occurred when clicking on email but and the error is not unavailable. On Android I get this error:
Error:The modules ['RNMail', 'react-native-mail'] point to the same directory in the file system.
Each module must have a unique path.
Any help is appreciated.
Thanks,
viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
Causes a crash in all of my 9.3 devices. 9.2 devices work perfectly
xCode build fails with no indication of why after I add libRNMail.a to the Link Binary With Libraries section of Build Phases, anyone seen this before?
send mail doesnt work in react native
Hi @chirag04 I went through the steps in the android instructions but when i put the following code in my MainActivity.java
it throws all kinds of erros when trying to run on android any suggestions?
Some of The Errors in Console
symbol: class Bundle
location: class MainActivity
/Users/jeremypagley/Desktop/Code Projects/CelebrationApp/android/app/src/main/java/com/celebrationapp/MainActivity.java:14: error: method does not override or implement a method from a supertype
@Override
^
/Users/jeremypagley/Desktop/Code Projects/CelebrationApp/android/app/src/main/java/com/celebrationapp/MainActivity.java:16: error: cannot find symbol
super.onCreate(savedInstanceState);
^
symbol: variable super
location: class MainActivity
/Users/jeremypagley/Desktop/Code Projects/CelebrationApp/android/app/src/main/java/com/celebrationapp/MainActivity.java:17: error: cannot find symbol
mReactRootView = new ReactRootView(this);
^
symbol: variable mReactRootView
location: class MainActivity
/Users/jeremypagley/Desktop/Code Projects/CelebrationApp/android/app/src/main/java/com/celebrationapp/MainActivity.java:17: error: cannot find symbol
mReactRootView = new ReactRootView(this);
^
symbol: class ReactRootView
location: class MainActivity
/Users/jeremypagley/Desktop/Code Projects/CelebrationApp/android/app/src/main/java/com/celebrationapp/MainActivity.java:19: error: cannot find symbol
mReactInstanceManager = ReactInstanceManager.builder()
^
symbol: variable mReactInstanceManager
location: class MainActivity
/Users/jeremypagley/Desktop/Code Projects/CelebrationApp/android/app/src/main/java/com/celebrationapp/MainActivity.java:26: error: cannot find symbol
.setInitialLifecycleState(LifecycleState.RESUMED)
^
symbol: variable LifecycleState
location: class MainActivity
/Users/jeremypagley/Desktop/Code Projects/CelebrationApp/android/app/src/main/java/com/celebrationapp/MainActivity.java:20: error: cannot find symbol
.setApplication(getApplication())
^
symbol: method getApplication()
location: class MainActivity
/Users/jeremypagley/Desktop/Code Projects/CelebrationApp/android/app/src/main/java/com/celebrationapp/MainActivity.java:19: error: cannot find symbol
mReactInstanceManager = ReactInstanceManager.builder()
^
symbol: variable ReactInstanceManager
location: class MainActivity
/Users/jeremypagley/Desktop/Code Projects/CelebrationApp/android/app/src/main/java/com/celebrationapp/MainActivity.java:29: error: cannot find symbol
mReactRootView.startReactApplication(mReactInstanceManager, "ExampleRN", null);
^
symbol: variable mReactInstanceManager
location: class MainActivity
/Users/jeremypagley/Desktop/Code Projects/CelebrationApp/android/app/src/main/java/com/celebrationapp/MainActivity.java:29: error: cannot find symbol
mReactRootView.startReactApplication(mReactInstanceManager, "ExampleRN", null);
^
symbol: variable mReactRootView
location: class MainActivity
/Users/jeremypagley/Desktop/Code Projects/CelebrationApp/android/app/src/main/java/com/celebrationapp/MainActivity.java:31: error: cannot find symbol
setContentView(mReactRootView);
^
symbol: variable mReactRootView
location: class MainActivity
/Users/jeremypagley/Desktop/Code Projects/CelebrationApp/android/app/src/main/java/com/celebrationapp/MainActivity.java:38: error: method does not override or implement a method from a supertype
@Override
^
/Users/jeremypagley/Desktop/Code Projects/CelebrationApp/android/app/src/main/java/com/celebrationapp/MainActivity.java:47: error: method does not override or implement a method from a supertype
@Override
^
/Users/jeremypagley/Desktop/Code Projects/CelebrationApp/android/app/src/main/java/com/celebrationapp/MainActivity.java:56: error: method does not override or implement a method from a supertype
@Override
^
17 errors
:app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 7.132 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
MainActivity.java
package com.celebrationapp;
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.chirag.RNMail.*;
import java.util.Arrays;
import java.util.List;
public class MainActivity extends ReactActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.addPackage(new RNMail()) // <------ add here
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "ExampleRN", null);
setContentView(mReactRootView);
}
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "CelebrationApp";
}
/**
* Returns whether dev mode should be enabled.
* This enables e.g. the dev menu.
*/
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
/**
* A list of packages used by the app. If the app uses additional views
* or modules besides the default ones, add more packages here.
*/
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
);
}
}
as you can see I added the @Override > onCreate
method but when running on an android device it instantly throws those errors above any idea as to what I missed? Thanks in advance for your time
ps I have it works perfect on ios :D
event after email being sent is not fired on android
Is there a permission associated with this?
I'm sure this is dead simple but can we have a method (maybe named open
) that just launches the user's mail application but doesn't compose a message?
May you please add screenshots (ideally GIF) of this in action in repo? That's the first thing a lot of RN package searchers do. There are so many packages its not easy to install each one, render it respecting properties, then uninstall it if it doesn't fit.
Hey does this work on an iPhone emulator (using XCode?)
I am trying to test and it doesn't seem to work. It works on my android device.
Or do I actually have to use a physical device in order for it to work?
Please let me know.
Thanks
after install and link, but it show error : undefined is not an object (evaluating '_reactNativeMail2.default.mail') when call
handleEmail = () => {
Mailer.mail({
subject: 'need help',
recipients: ['[email protected]'],
ccRecipients: ['[email protected]'],
bccRecipients: ['[email protected]'],
body: 'A Bold Body',
isHTML: true,
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) => {
Alert.alert(
error,
event,
[
{ text: 'Ok', onPress: () => console.log('OK: Email Error Response') },
{ text: 'Cancel', onPress: () => console.log('CANCEL: Email Error Response') }
],
{ cancelable: true }
)
});
}
Hi,
I am using this module when I click on email in my app then the mail screen has to appear
but here I am getting an error in console as not_available
can anyone help me to solve this
When I execute Mailer.mail()
, it popup mail modal and immediately close mail modal and showing:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI isEqualToString:]: unrecognized selector sent to instance 0x7fb7fa6565a0' terminating with uncaught exception of type NSException abort() called
Hello.
I have an issue that the event after the letter is sent is not fired. So i cannot handle some actions. Can you recommend something?
Hi guys,
Whenever I install the version 2.0.1 of this package, I get " UNMET PEER DEPENDENCY" error
npm i --save [email protected]
โโโ UNMET PEER DEPENDENCY [email protected]
โโโ [email protected]
What does this error mean? Any idea what I am doing wrong?
This is my rn version
react-native -v
react-native-cli: 1.2.0
react-native: 0.38.0
Just wondering if
rnpm link
or
react-native link
works with this. I like that there are instructions for setting up on both platforms, but I really like it being done by typing in a single command more. If it does work, can you add this to the readme?
Also - readme might look better with es6 syntax
I am trying to send a photo by mail with the help of this module and get the following error:
index.ios.bundle:28842Exception '-[MFMailComposeInternalViewController addAttachmentData:mimeType:fileName:] attachment must not be nil.' was thrown while invoking mail on target RNMail with params (
{
attachment = {
name = Ladunek;
path = "assets-library://asset/asset.JPG?id=3B7DBB2E-1271-4D86-A5F2-A0CEEE7CC4DE&ext=JPG";
type = jpg;
};
body = "body";
isHTML = 1;
recipients = (
"[email protected]"
);
subject = Ladunek;
},
9
)
This is the invoking code :
.then((data, path) => {
console.log(data)
console.log(data.path)
Mailer.mail({
subject: 'Ladunek',
recipients: ['[email protected]'],
body: 'body',
isHTML: true, // iOS only, exclude if false
attachment: {
path: data.path, // The absolute path of the file from which to read data.
type: 'jpg', // Mime Type: jpg, png, doc, ppt, html, pdf
name: 'Ladunek', // Optional: Custom filename for attachment
}
}, (error, event) => {
if(error) {
AlertIOS.alert('Error', 'Could not send mail. Please send a mail to [email protected]');
}
});
})
Is the path invalid? Or might it be something else.
Warning: Attempt to present <MFMailComposeViewController: 0x13e150c00> on <UIViewController: 0x13d6bc8e0> whose view is not in the window hierarchy!
First, a great module to send email.
Do you have any plan to add the support to send attachments?
When I try to build to real device I get this error:
Does anyone knows how to fix it?
Hello,
Thanks to share your work.
I use react-native 0.32 and there is no onCreate() method in mainActivity.java
To add a package, you have to declare it in method getPackages() of the MainApplication.java and of course import the module in it (and not in mainActivity.java)
Do you wan't I make a pull request ?
regards
I don't know what's different from every other react native package, but with react-native-mail
, npm ALWAYS reinstalls it every time I run npm install
. Consecutive npm install
s should not do that.
Hello, when i tried to run my app that uses module RNMail, i got error. I logged it and it shows me in console 'not available'
I use RN 0.39.2
How may i fix it?
This is probably a javascript newbie problem. What would syntax look like for multiple email file attachments?
I tried the following which is apparently not correct javascript. My goal is to iterate through my fileAttachmentList array and build the Mailer.mail attachment object.
Mailer.mail({
subject: subjectText,
recipients: ['[email protected]'],
body: bodyText,
attachment: {
path: this.state.fileAttachmentList[0].fileNamePath,
type: this.state.fileAttachmentList[0].fileMimeType,
name: this.state.fileAttachmentList[0].fileName,
},
{
path: this.state.fileAttachmentList[1].fileNamePath,
type: this.state.fileAttachmentList[1].fileMimeType,
name: this.state.fileAttachmentList[1].fileName,
}
}, (error, event) => {
if(error) {
Alert.alert('Error', 'Could not send mail');
}
});
Thank you very much for sharing your work on such a great react-component !
I got an error message:
* What went wrong:
A problem occurred configuring project ':app'.
> Cannot evaluate module RNMail : Configuration with name 'default' not found.
I added it to settings.gradle
include ':RNMail'
project(':RNMail').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-mail/android')
for build.gradle
compile project(':RNMail')
as well as on MainApplication.java. I'm using RN 0.40.0
I seem to be having a problem getting a good HTML email sent out by android. It looks great on iOS, but it seems on Android that only the br tags are respected, all other text formatting and inline CSS styling is ignored.
Using a GMail account on both iOS and Android for delivery.
Promise rejection on Android
Config:
"react-native": "0.48.4",
"react-native-mail": "^3.0.5",
I am not sure if this is the correct place to ask this question but I am unable to find any other place that discusses react-native-mail.
I tried using the example code provided in my app, but got the error
"Exception '-[MFMailComposeInternalViewController addAttachmentData:mimeType:fileName:] attachment must not be nil.' was thrown while invoking mail on target RNMail with params (
{
attachment = {
name = default;
path = "./res/default.png";
type = png;
};
body = "";
isHTML = 1;
recipients = (
"[email protected]"
);
subject = "Test Subject";
},
265
)"
My code is provided below. If I comment out the attachment part, the email pops up as expected with subject and recipients fields filled out. I wonder if there is a problem with how I enter the path. I've also tried 'projName/js/res/default.png' but that did not work out either. The file is at the correct location as I am using the same picture somewhere else in the class by calling require('./res/default.png)' and that picture loads.
Any help would be appreciated. Thank you.
sendEmail: function() {
Mailer.mail({
subject: 'Test Subject',
recipients: '[email protected]',
body: '',
isHTML: true,
attachment: {
path: './res/default.png',
type: 'png',
name: 'default',
}
}, (error, event) => {
if(error) {
AlertIOS.alert('Error', 'Could not send mail.');
}
});
},
Hello,
After following the installation instructions for an iOS project, I added
var Mailer = require('NativeModules').RNMail;
to the top of a class which uses react-native-mail, and added the Mailer.mail({...});
example to an existing function that is intended to eventually send mail. Unfortunately when testing the functionality of "Mailer.mail" I received an error indicating "Cannot read property 'mail' of undefined."
Here is a screenshot of my Xcode build phases, with RNMail.xcodeproj shown in the libraries folder within the project navigator: https://i.gyazo.com/8c8739fcab756a9183be8b102795ccde.png
Here is a screenshot of the error indicated in the simulator: https://i.gyazo.com/c016612a77a4acd11f7f46c8a51a27c2.png
I am also receiving this stderr output from the build (which makes me think this problem lies within the installation):
** BUILD FAILED **
The following build commands failed:
CompileC /Users/williamlamason/Desktop/work/JSenderIOS/ios/build/Build/Intermediates/RNMail.build/Debug-iphonesimulator/RNMail.build/Objects-normal/x86_64/RNMail.o RNMail/RNMail.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Please let me know what I might be doing wrong when including react-native-mail into my project.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.