Git Product home page Git Product logo

xk6-imap's Introduction

Examples

Gmail

Google removed plain username+password authentication for 3rd party. You need to create a "App password" to be able to use username+password for authentication.

import Imap from "k6/x/imap";

export default function () {
  const [message, error] = Imap.read(
    "[email protected]",
    "password123",
    "imap.gmail.com",
    993,
    {
      Subject: ["Verify your email"],
    }
  );

  if (error != "") {
    console.error(error);
  } else {
    console.log(message);
  }
}

emailClient

Use email client if you need to read multiple messages and don't want to login everytime.

import imap from "k6/x/imap";

export default function () {
  const client = imap.emailClient(
    "[email protected]",
    "password123",
    "imap.gmail.com",
    993
  );

  const loginError = client.login();

  if (loginError != "") {
    console.error(loginError);
    return;
  }

  let [message, err] = client.read({
    Subject: ["Verify your email"],
  });

  if (err != "") {
    console.error(err);
    return;
  }

  console.log(message);
  client.logOut();
}

Build

Don't forget to use this binary instead of the k6 binary in your path.

xk6 build --with github.com/eugercek/xk6-imap

# ./k6 run script.js

TODO List

  • Give examples for major email providers
  • Give examples for how to measure elapsed time
  • Create unit tests for the Go code
  • Expose more query options

xk6-imap's People

Contributors

eugercek avatar

Stargazers

taha avatar Roman avatar

Watchers

taha avatar  avatar

xk6-imap's Issues

The parameters of the read function

hello,

First of all, thank you for creating this extension. I think she will be able to help me to do tests on the receipt of emails.

Unfortunately, I have a problem with the parameters that the read function can take.
When I want to retrieve an email with just the subject, I have an infinite call when I have several emails that have the same subject.
I would like to filter by the To receiver but when I add this new parameter, as follows:

let [message, err] = client.read({ Subject: ['Subject of email'], To: ['[email protected]'], });

I have the following error:

Command Argument Error. 11

Thank you in advance, if you have the opportunity to answer me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.