Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
@jackmahoney jackmahoney v8.6.0 e9348f1 Mar 29, 2020
1 contributor

Users who have contributed to this file

542 lines (325 sloc) 15.4 KB

MailSlurp JSGlobals"index"MailSlurp

Class: MailSlurp

Official MailSlurp Client

Install

npm install --save mailslurp-client

Configure

Create a MailSlurp account to get an API Key.

const MailSlurp = require('mailslurp-client').default;
const mailslurp = new MailSlurp({ apiKey: 'xxxx' })

Make requests

const inbox = await mailslurp.createInbox()
await mailslurp.sendEmail({ to: [inbox.emailAddress] })
const email = await mailslurp.waitForLatestEmail(inbox.id)

Read quick start guide for more examples or see the methods below.

Hierarchy

  • MailSlurp

Index

Constructors

Properties

Methods

Constructors

constructor

+ new MailSlurp(opts: Config): MailSlurp

Defined in src/index.ts:84

Create a new MailSlurp instance

Parameters:

Name Type Description
opts Config

Returns: MailSlurp

Properties

attachmentController

attachmentController: AttachmentControllerApi

Defined in src/index.ts:74


bulkController

bulkController: BulkActionsControllerApi

Defined in src/index.ts:77


commonController

commonController: CommonActionsControllerApi

Defined in src/index.ts:76


contactController

contactController: ContactControllerApi

Defined in src/index.ts:81


domainController

domainController: DomainControllerApi

Defined in src/index.ts:80


emailController

emailController: EmailControllerApi

Defined in src/index.ts:72


groupController

groupController: GroupControllerApi

Defined in src/index.ts:82


inboxController

inboxController: InboxControllerApi

Defined in src/index.ts:73


templateController

templateController: TemplateControllerApi

Defined in src/index.ts:83


waitController

waitController: WaitForControllerApi

Defined in src/index.ts:78


webhookController

webhookController: WebhookControllerApi

Defined in src/index.ts:84

Methods

createInbox

createInbox(emailAddress?: string, name?: string, description?: string, expiresAt?: Date, favourite?: boolean, tags?: Array‹string›): Promise‹Inbox

Defined in src/index.ts:162

Parameters:

Name Type
emailAddress? string
name? string
description? string
expiresAt? Date
favourite? boolean
tags? Array‹string›

Returns: Promise‹Inbox


deleteEmail

deleteEmail(emailId: string): Promise‹Response›

Defined in src/index.ts:296

Parameters:

Name Type
emailId string

Returns: Promise‹Response›


deleteInbox

deleteInbox(inboxId: string): Promise‹Response›

Defined in src/index.ts:182

Parameters:

Name Type
inboxId string

Returns: Promise‹Response›


downloadAttachment

downloadAttachment(emailId: string, attachmentId: string): Promise‹String›

Defined in src/index.ts:392

Get email attachment by id

Returns HTTP response containing byte stream

Parameters:

Name Type
emailId string
attachmentId string

Returns: Promise‹String›


emptyInbox

emptyInbox(inboxId: string): Promise‹Response›

Defined in src/index.ts:188

Parameters:

Name Type
inboxId string

Returns: Promise‹Response›


getAllEmails

getAllEmails(page?: number, size?: number, inboxId?: Array‹string›, sort?: SortEnum, unreadOnly?: boolean): Promise‹PageEmailProjection

Defined in src/index.ts:306

Get all emails Returns paginated email previews

Parameters:

Name Type
page? number
size? number
inboxId? Array‹string›
sort? SortEnum
unreadOnly? boolean

Returns: Promise‹PageEmailProjection


getAllInboxes

getAllInboxes(page?: number, size?: number, favourite?: boolean, search?: string, sort?: SortEnum, tag?: string): Promise‹PageInboxProjection

Defined in src/index.ts:213

Get all inboxes paginated Returns paginated inbox previews

Parameters:

Name Type
page? number
size? number
favourite? boolean
search? string
sort? SortEnum
tag? string

Returns: Promise‹PageInboxProjection


getAttachmentMetaData

getAttachmentMetaData(attachmentId: string, emailId: string): Promise‹AttachmentMetaData

Defined in src/index.ts:419

Get attachment MetaData

MetaData includes name, size (bytes) and content-type.

Parameters:

Name Type
attachmentId string
emailId string

Returns: Promise‹AttachmentMetaData


getEmail

getEmail(emailId: string): Promise‹Email

Defined in src/index.ts:355

Get a full email from by id. To get an emails ID use the getEmails or waitFor methods with an inbox

[[include: get-email.md]]

Parameters:

Name Type Description
emailId string

Returns: Promise‹Email


getEmails

getEmails(inboxId: string, args: GetMessagesOptions): Promise‹EmailPreview[]›

Defined in src/index.ts:332

Get all emails in an inbox as EmailPreviews. To get the full email, use the getEmail endpoint

[[include: get-emails.md]]

Parameters:

Name Type Default Description
inboxId string - -
args GetMessagesOptions {}

Returns: Promise‹EmailPreview[]›


getInbox

getInbox(inboxId: string): Promise‹Inbox

Defined in src/index.ts:194

Parameters:

Name Type
inboxId string

Returns: Promise‹Inbox


getInboxes

getInboxes(): Promise‹Inbox[]›

Defined in src/index.ts:205

Get all inboxes

[[include: list-inboxes.md]]

Returns: Promise‹Inbox[]›


getRawEmail

getRawEmail(emailId: string): Promise‹string›

Defined in src/index.ts:365

Get an email's raw contents from by id

Parameters:

Name Type Description
emailId string

Returns: Promise‹string›


sendEmail

sendEmail(inboxId: string, sendEmailOptions: SendEmailOptions): Promise‹Response›

Defined in src/index.ts:378

Send and email from a given inbox

[[include: send-email.md]]

Parameters:

Name Type Description
inboxId string -
sendEmailOptions SendEmailOptions

Returns: Promise‹Response›


uploadAttachment

uploadAttachment(options: UploadAttachmentOptions): Promise‹Array‹String››

Defined in src/index.ts:406

Upload an attachment for use in email sending

Attachment contents must be a base64 encoded string

Parameters:

Name Type
options UploadAttachmentOptions

Returns: Promise‹Array‹String››


waitForEmailCount

waitForEmailCount(count?: number, inboxId?: string, timeout?: number, unreadOnly?: boolean): Promise‹EmailPreview[]›

Defined in src/index.ts:279

Parameters:

Name Type
count? number
inboxId? string
timeout? number
unreadOnly? boolean

Returns: Promise‹EmailPreview[]›


waitForLatestEmail

waitForLatestEmail(inboxId?: string, timeout?: number, unreadOnly?: boolean): Promise‹Email

Defined in src/index.ts:235

Parameters:

Name Type
inboxId? string
timeout? number
unreadOnly? boolean

Returns: Promise‹Email


waitForMatchingEmails

waitForMatchingEmails(matchOptions: MatchOptions, count?: number, inboxId?: string, timeout?: number, unreadOnly?: boolean): Promise‹EmailPreview[]›

Defined in src/index.ts:261

Parameters:

Name Type
matchOptions MatchOptions
count? number
inboxId? string
timeout? number
unreadOnly? boolean

Returns: Promise‹EmailPreview[]›


waitForNthEmail

waitForNthEmail(inboxId: string, index: number, timeout?: number, unreadOnly?: boolean): Promise‹Email

Defined in src/index.ts:245

Parameters:

Name Type
inboxId string
index number
timeout? number
unreadOnly? boolean

Returns: Promise‹Email

You can’t perform that action at this time.