GoLang Documentation

How to send and receive emails in Golang. Generate email addresses on demand.

\ExtraOperationsApi

All URIs are relative to https://api.mailslurp.com

Method HTTP request Description
BulkCreateInboxes Post /bulk/inboxes Bulk create Inboxes (email addresses)
BulkDeleteInboxes Delete /bulk/inboxes Bulk Delete Inboxes
BulkSendEmails Post /bulk/send Bulk Send Emails
CreateDomain Post /domains Create Domain
CreateInbox Post /inboxes Create an Inbox (email address)
CreateWebhook Post /inboxes/{inboxId}/webhooks Attach a WebHook URL to an inbox
DeleteDomain Delete /domains/{id} Delete a domain
DeleteEmail1 Delete /emails/{emailId} Delete Email
DeleteInbox Delete /inboxes/{inboxId} Delete Inbox / Email Address
DeleteWebhook Delete /inboxes/{inboxId}/webhooks/{webhookId} Delete and disable a WebHook for an Inbox
DownloadAttachment Get /emails/{emailId}/attachments/{attachmentId} Get email attachment
ForwardEmail Post /emails/{emailId}/forward Forward Email
GetDomain Get /domains/{id} Get a domain
GetDomains Get /domains Get domains
GetEmail Get /emails/{emailId} Get Email Content
GetEmails Get /inboxes/{inboxId}/emails List Emails in an Inbox / EmailAddress
GetEmailsPaginated Get /emails Get all emails
GetInbox Get /inboxes/{inboxId} Get Inbox / EmailAddress
GetInboxes Get /inboxes List Inboxes / Email Addresses
GetRawEmailContents Get /emails/{emailId}/raw Get Raw Email Content
GetWebhooks Get /inboxes/{inboxId}/webhooks Get all WebHooks for an Inbox
SendEmail Post /inboxes/{inboxId} Send Email
UploadAttachment Post /attachments Upload an attachment for sending
UploadMultipartForm Post /attachments/multipart Upload an attachment for sending using Multipart Form

BulkCreateInboxes

[]Inbox BulkCreateInboxes(ctx, count) Bulk create Inboxes (email addresses)

Enterprise Plan Required

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
count int32 Number of inboxes to be created in bulk

Return type

[]Inbox

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

BulkDeleteInboxes

BulkDeleteInboxes(ctx, requestBody) Bulk Delete Inboxes

Enterprise Plan Required

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
requestBody []string ids

Return type

(empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: application/json
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

BulkSendEmails

BulkSendEmails(ctx, bulkSendEmailOptions) Bulk Send Emails

Enterprise Plan Required

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
bulkSendEmailOptions BulkSendEmailOptions bulkSendEmailOptions

Return type

(empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: application/json
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

CreateDomain

DomainPlusVerificationRecordsAndStatus CreateDomain(ctx, createDomainOptions) Create Domain

Link a domain that you own with MailSlurp so you can create inboxes with it. Returns DNS records used for validation. You must add these verification records to your host provider's DNS setup to verify the domain.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
createDomainOptions CreateDomainOptions domainOptions

Return type

[DomainPlusVerificationRecordsAndStatus](Domain plus verification records and status.md)

Authorization

API_KEY

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

CreateInbox

Inbox CreateInbox(ctx, optional) Create an Inbox (email address)

Create a new inbox and with a ranmdomized email address to send and receive from. Pass emailAddress parameter if you wish to use a specific email address. Creating an inbox is required before sending or receiving emails. If writing tests it is recommended that you create a new inbox during each test method so that it is unique and empty.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
optional *CreateInboxOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a CreateInboxOpts struct

Name Type Description Notes
emailAddress optional.String Optional email address including domain you wish inbox to use (eg: test123@mydomain.com). Only supports domains that you have registered and verified with MailSlurp using dashboard or `createDomain` method.

Return type

Inbox

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

CreateWebhook

Webhook CreateWebhook(ctx, inboxId, createWebhookOptions) Attach a WebHook URL to an inbox

Get notified whenever an inbox receives an email via a WebHook URL. An emailID will be posted to this URL every time an email is received for this inbox. The URL must be publicly reachable by the MailSlurp server. You can provide basicAuth values if you wish to secure this endpoint.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
inboxId string inboxId
createWebhookOptions CreateWebhookOptions webhookOptions

Return type

Webhook

Authorization

API_KEY

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

DeleteDomain

DeleteDomain(ctx, id) Delete a domain

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
id string id

Return type

(empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

DeleteEmail1

DeleteEmail1(ctx, emailId) Delete Email

Deletes an email and removes it from the inbox

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
emailId string emailId

Return type

(empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

DeleteInbox

DeleteInbox(ctx, inboxId) Delete Inbox / Email Address

Permanently delete an inbox and associated email address

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
inboxId string inboxId

Return type

(empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

DeleteWebhook

DeleteWebhook(ctx, inboxId, webhookId) Delete and disable a WebHook for an Inbox

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
inboxId string inboxId
webhookId string webhookId

Return type

(empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

DownloadAttachment

DownloadAttachment(ctx, attachmentId, emailId, optional) Get email attachment

Returns the specified attachment for a given email as a byte stream (file download). Get the attachmentId from the email response. Requires enterprise account.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
attachmentId string attachmentId
emailId string emailId
optional *DownloadAttachmentOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a DownloadAttachmentOpts struct

Name Type Description Notes

apiKey | optional.String| Can pass apiKey in url for this request if you wish to download the file in a browser |

Return type

(empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ForwardEmail

ForwardEmail(ctx, emailId, forwardEmailOptions) Forward Email

Forward email content to given recipients

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
emailId string emailId
forwardEmailOptions ForwardEmailOptions forwardEmailOptions

Return type

(empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: application/json
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetDomain

DomainPlusVerificationRecordsAndStatus GetDomain(ctx, id) Get a domain

Returns domain verification status and tokens

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
id string id

Return type

[DomainPlusVerificationRecordsAndStatus](Domain plus verification records and status.md)

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetDomains

[]DomainPreview GetDomains(ctx, ) Get domains

Required Parameters

This endpoint does not need any parameter.

Return type

[]DomainPreview

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetEmail

Email GetEmail(ctx, emailId) Get Email Content

Returns a email summary object with headers and content. To retrieve the raw unparsed email use the getRawMessage endpoint

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
emailId string emailId

Return type

Email

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetEmails

[]EmailPreview GetEmails(ctx, inboxId, optional) List Emails in an Inbox / EmailAddress

List emails that an inbox has received. Only emails that are sent to the inbox's email address will appear in the inbox. It may take several seconds for any email you send to an inbox's email address to appear in the inbox. To make this endpoint wait for a minimum number of emails use the minCount parameter. The server will retry the inbox database until the minCount is satisfied or the retryTimeout is reached

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
inboxId string Id of inbox that emails belongs to
optional *GetEmailsOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a GetEmailsOpts struct

Name Type Description Notes

limit | optional.Int32| Limit the result set, ordered by descending received date time | minCount | optional.Int64| Minimum acceptable email count. Will cause request to hang (and retry) until minCount is satisfied or retryTimeout is reached. | retryTimeout | optional.Int64| Maximum milliseconds to spend retrying inbox database until minCount emails are returned | since | optional.Time| Exclude emails received before this ISO 8601 date time |

Return type

[]EmailPreview

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetEmailsPaginated

PageEmailProjection GetEmailsPaginated(ctx, optional) Get all emails

Responses are paginated

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
optional *GetEmailsPaginatedOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a GetEmailsPaginatedOpts struct

Name Type Description Notes
page optional.Int32 Optional page index in email list pagination [default to 0]
size optional.Int32 Optional page size in email list pagination [default to 20]

Return type

PageEmailProjection

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetInbox

Inbox GetInbox(ctx, inboxId) Get Inbox / EmailAddress

Returns an inbox's properties, including its email address and ID.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
inboxId string inboxId

Return type

Inbox

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetInboxes

[]Inbox GetInboxes(ctx, ) List Inboxes / Email Addresses

List the inboxes you have created

Required Parameters

This endpoint does not need any parameter.

Return type

[]Inbox

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetRawEmailContents

string GetRawEmailContents(ctx, emailId) Get Raw Email Content

Returns a raw, unparsed and unprocessed email

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
emailId string emailId

Return type

string

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: text/plain

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetWebhooks

[]Webhook GetWebhooks(ctx, inboxId) Get all WebHooks for an Inbox

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
inboxId string inboxId

Return type

[]Webhook

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

SendEmail

SendEmail(ctx, inboxId, sendEmailOptions) Send Email

Send an email from the inbox's email address. Specify the email recipients and contents in the request body. See the SendEmailOptions for more information. Note the inboxId refers to the inbox's id NOT its email address

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
inboxId string inboxId
sendEmailOptions SendEmailOptions sendEmailOptions

Return type

(empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: application/json
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

UploadAttachment

[]string UploadAttachment(ctx, uploadAttachmentOptions) Upload an attachment for sending

When sending emails with attachments first upload each attachment with this endpoint. Record the returned attachment IDs. Then use these attachment IDs in the SendEmailOptions when sending an email. This means that attachments can easily be reused.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
uploadAttachmentOptions UploadAttachmentOptions uploadOptions

Return type

[]string

Authorization

API_KEY

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

UploadMultipartForm

[]string UploadMultipartForm(ctx, file, optional) Upload an attachment for sending using Multipart Form

When sending emails with attachments first upload each attachment with this endpoint. Record the returned attachment IDs. Then use these attachment IDs in the SendEmailOptions when sending an email. This means that attachments can easily be reused.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
file *os.File***os.File** file
optional *UploadMultipartFormOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a UploadMultipartFormOpts struct

Name Type Description Notes

contentType | optional.String| contentType | filename | optional.String| filename |

Return type

[]string

Authorization

API_KEY

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]