A React Native plugin for managing email inbox operations.
- Install the package:
npm install react-native-inbox
# or
yarn add react-native-inbox
- Link the native modules:
For iOS:
cd ios && pod install && cd ..
For Android: The module will be automatically linked in React Native 0.60 and above.
import Inbox from 'react-native-inbox';
// Connect to email server
const connectToEmail = async () => {
try {
await Inbox.connect({
host: 'imap.gmail.com',
port: 993,
username: 'your-email@gmail.com',
password: 'your-password',
useSSL: true
});
console.log('Connected successfully');
} catch (error) {
console.error('Connection failed:', error);
}
};
// Download emails
const getEmails = async () => {
try {
const emails = await Inbox.getEmails({
folder: 'INBOX',
limit: 10
});
console.log('Emails:', emails);
} catch (error) {
console.error('Failed to download emails:', error);
}
};
// Get available folders
const getFolders = async () => {
try {
const folders = await Inbox.getFolders();
console.log('Available folders:', folders);
} catch (error) {
console.error('Failed to get folders:', error);
}
};
// Disconnect from email server
const disconnect = async () => {
try {
await Inbox.disconnect();
console.log('Disconnected successfully');
} catch (error) {
console.error('Disconnect failed:', error);
}
};
Connects to an email server.
Parameters:
-
config
(Object):-
host
(string): Email server host -
port
(number): Email server port -
username
(string): Email username -
password
(string): Email password -
useSSL
(boolean): Whether to use SSL
-
Disconnects from the email server.
Downloads emails from a specific folder.
Parameters:
-
options
(Object):-
folder
(string): Folder name (e.g., 'INBOX') -
limit
(number): Maximum number of emails to download
-
Returns a list of available folders.
- Uses MailCore2 library for email functionality
- Requires iOS 9.0 or later
- Make sure to run
pod install
in the ios directory after installation
- Uses JavaMail API for email functionality
- Requires Android API level 21 or later
- No additional setup required
MIT