npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@matthiasn/react-native-mailcore

v0.1.0-9

Published

React Native bindings for https://github.com/MailCore/mailcore2

Downloads

10

Readme

react-native-mailcore

react native bindings for https://github.com/MailCore/mailcore2

npm version npm downloads

Stability status: alpha

Setup

  • yarn add react-native-mailcore

  • react-native link react-native-mailcore

  • For ios, setup pods for your project. Go to ios directory in your project. See https://github.com/MailCore/mailcore2/blob/master/build-mac/README.md#cocoapods

    • If you havent setup pods for your project run pod init in your ios directory.

    • Add pod 'mailcore2-ios' to your Podfile. Example

        # Uncomment the next line to define a global platform for your project
        # platform :ios, '9.0'
      
        target 'BasicExample' do
          # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
          # use_frameworks!
      
          # Pods for BasicExample
      
          pod 'mailcore2-ios'
      
          target 'BasicExampleTests' do
            inherit! :search_paths
            # Pods for testing
          end
      
        end
      
        target 'BasicExample-tvOS' do
          # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
          # use_frameworks!
      
          # Pods for BasicExample-tvOS
      
          target 'BasicExample-tvOSTests' do
            inherit! :search_paths
            # Pods for testing
          end
      
        end
    • pod install

  • For android,

    • copy paste the following lines in to settings.gradle
    include ':mailcore2-android-4'
    project(':mailcore2-android-4').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-mailcore/mailcore2-android-4')
    • Add the following code to app/build.gradle of your app.

      • For android tools version com.android.tools.build:gradle:2.2.3

          import com.android.build.gradle.internal.pipeline.TransformTask
        
          def deleteDuplicateJniFiles() {
              def files = fileTree("${buildDir}/intermediates/exploded-aar/com.facebook.react/react-native/0.43.3/jni/") {
                  include "**/libgnustl_shared.so"
              }
              files.each { it.delete() }
          }
        
          tasks.withType(TransformTask) { pkgTask ->
              pkgTask.doFirst { deleteDuplicateJniFiles() }
          }
        • Make sure to change the react-native version properly
      • For android tools version com.android.tools.build:gradle:2.3.3

        android {
          ...
          ...
          ...
          ...
          ...
            packagingOptions{
                pickFirst '**/libgnustl_shared.so'
            }
        }

Usage

  • Note: For any of the following methods you must first use loginImap
  • Note: For SendMail method you must first use loginSmtp
  • Note: For the use of attachments download remember to give permission to the application
import MailCore from 'react-native-mailcore';
  • Login smtp
  MailCore.loginSmtp({
    hostname: 'smtp.gmail.com',
    port: 465,
    username: '[email protected]',
    password: 'password',
  }).then(result => {
    alert(result.status);
  })
  .catch(error => {
    alert(error);
  });
  • Login imap
MailCore.loginImap({
    hostname: 'imap.gmail.com',
    port: 993,
    username: '[email protected]',
    password: 'password',
  }).then(result => {
    alert(result.status);
  })
  .catch(error => {
    alert(error);
  });
  • Create Folder
  MailCore.createFolder({
    folder: 'newfoldername'
  }).then(result => {
    alert(result.status);
  })
  .catch(error => {
    alert(error);
  });
  • Rename folder
MailCore.renameFolder({
  folderOldName: 'oldFolderName',
  folderNewName: 'newFolderName'
}).then(result => {
  alert(result.status);
})
.catch(error => {
  alert(error);
});
  • Delete folder
  MailCore.deleteFolder({
    folder: 'folderName'
  }).then(result => {
    alert(result.status);
  })
  .catch(error => {
    alert(error);
  });
  • List folders
MailCore.getFolders()
.then(result => {
  const a = [...result.folders];
  a.forEach(element => {
    alert(element.path);
  });
})
.catch(error => {
    alert(error);
});
  • Move Email
  MailCore.moveEmail({
    folderFrom: 'oldfolder',
    messageId: 14,
    folderTo: 'newfolder'
  })
  .then(result => {
    alert(result.status);
  })
  .catch(error => {
      alert(error);
  });
  • Permant Email Delete
  MailCore.permantDeleteEmail({
    folderFrom: 'folder',
    messageId: messageId
  })
  .then(result => {
      alert(result.status);
  })
  .catch(error => {
      alert(error);
  });
  • Action Flag Message
  MailCore.actionFlagMessage({
    folder: 'folder',
    messageId: messageId,
    flagsRequestKind: <FlagsRequestKind val int>,
    messageFlag: <MessageFlag val int>
  })
  .then(result => {
      alert(result.status);
  })
  .catch(error => {
      alert(error);
  
  });
  • Action label Message
  MailCore.actionLabelMessage({
    folder: 'folder',
    messageId: messageId,
    flagsRequestKind: <FlagsRequestKind val int>,
    tags: ["tag1","tag2","tag3"]
  })
  .then(result => {
      alert(result.status);
  })
  .catch(error => {
      alert(error);
  });
  • Send Mail
  MailCore.sendMail({
    headers: {
      key: 'value'
    },
    from: {
      addressWithDisplayName: 'from label',
      mailbox: '[email protected]'
    },
    to: {
      "[email protected]": 'to label',
      "[email protected]": 'to label'
    },
    cc: {
      "[email protected]": 'cc label',
      "[email protected]": 'cc label'
    },
    bcc: {
      "[email protected]": 'bcc label',
      "[email protected]": 'bcc label'
    },
    subject: 'subject',
    body: 'body',
    attachments: ["url/filename", "url/filename"]
  })
  .then(result => {
      alert(result.status);
  })
  .catch(error => {
      alert(error);
  });
  • Get mail
  MailCore.getMail({
  folder: 'folder',
  messageId: messageId,
  requestKind: <IMAPMessagesRequestKind val int>
  })
  .then(result => {
    let mail = {
      id: result.id,
      date: result.date,
      from: result.from,
      to: result.to,
      cc: result.cc,
      bcc: result.bcc,
      subject: result.subject,
      body: result.body,
      attachments: result.attachments
    }
    alert(result.status);
    console.log(mail)
  })
  .catch(error => {
      alert(error);
  });
  • Get Attachment
  MailCore.getAttachment({
    filename: 'filename',
    folder: 'folder',
    messageId: messageId,
    partID: 'partID',
    encoding: encoding,
    folderOutput: 'urlOutput'
  })
  .then(result => {
    alert(result.status);
  })
  .catch(error => {
      alert(error);
  });
  • List mails
  MailCore.getMails({
    folder: 'folder',
    requestKind: <IMAPMessagesRequestKind int value>
  })
  .then(result => {
    let promises = [];
    for (let i=0; i<result.mails.length;i++) {
      let mail = result.mails[i];
      let promise = new Promise((resolve,reject) => {
        MailCore.getMail({
          folder: 'folder',
          messageId: mail.id,
          requestKind: <IMAPMessagesRequestKind int value>
          }).then(mailDetails => {
            mail.body = mailDetails.body
            resolve(mail);
          })
          .catch(error => reject(error))
      });
      promises.push(promise)
    }
    Promise.all(promises)
    .then(mails => 
      console.log(mails))
  })
  .catch(error => {
      alert(error);
  });
}

TODO

  • [x] createFolder API support
  • [x] renameFolder API support
  • [x] deleteFolder API support
  • [x] listFolders API support
  • [x] imapLogin API support
  • [x] smtpLogin API support
  • [x] GetEmail API support
  • [x] MoveEmail API support
  • [x] DeleteEmail API support
  • [x] Download attachment
  • [x] SendEmail with attachments
  • [x] addFlags API support
  • [x] deleteFlags API support
  • [x] GetEmails API support
  • [ ] Basic Example