SMTP IMAP Mail Settings

How to access MailSlurp email accounts using IMAP and SMTP servers. Configure your mail clients or programming SDKs to use SMTP protocols.

  • Table of contents

smtp send and read email

See the IMAP/SMTP documentation for a developer guide.

MailSlurp gives you SMTP and IMAP access to email addresses that you create. For best results use the SMTP_INBOX type email mailbox when you create the address. You can get SMTP or IMAP access details inside the dashboard or by using the API to get your credentials.

Find your SMTP IMAP settings

Login to [your MailSlurp account](https://app.mailslurp.com/login/) or create a free account. On the dashboard homescreen you will see a tab of account details. Click the SMTP/IMAP tab to reveal your SMTP IMAP settings.

imap-access

Server overview

Here are the main URLs for IMAP and SMTP access:

Protocol Host Port TLS Description
SMTP mx.mailslurp.com 25 false SMTP server
SMTP mx.mailslurp.com 2525 false SMTP server
SMTP mailslurp.mx 587 true SMTP server (secure)
SMTP mailslurp.mx 2587 true SMTP server (secure)
SMTP mailslurp.mx 465 true SMTP server (secure)
SMTP mailslurp.mx 2465 true SMTP server (secure)
IMAP mailslurp.click 1143 false IMAP server
HTTP(S) api.mailslurp.com 80 true REST API server

Note that only inboxes created with the SMTP_INBOX mailbox type allow access via SMTP and IMAP. See the guide for differences in inbox type.

Get IMAP / SMTP access by curl

You can also access your SMTP or IMAP settings using the command line with your API_KEY.

curl api.mailslurp.com/inboxes/imap-smtp-access -Hx-api-key:YOUR_API_KEY
{"smtpServerHost":"mx.mailslurp.com","smtpServerPort":2525,"smtpUsername":"---","smtpPassword":"---","imapServerHost":"mailslurp.click","imapServerPort":1143,"imapUsername":"---","imapPassword":"---"}

Get IMAP / SMTP access in code and tests

There are methods in every offical code library like getImapSmtpAccessDetails that return the SMTP and IMAP settings for your account. Use these details to configure SMTP clients in your applications or tests.

const {MailSlurp} = require('mailslurp-client');
const nodemailer = require("nodemailer");
const apiKey = process.env.API_KEY;
const mailslurp = new MailSlurp({ apiKey });

// get access details for smpt server
const server = await mailslurp.getImapSmtpAccessDetails();

// use details to configure SMTP client like NodeMailer
const opts = {
    host: server.smtpServerHost,
    port: server.smtpServerPort,
    secure: false, // Disable tls recommended
    auth: {
        user: server.smtpUsername,
        pass: server.smtpPassword,
        type: "PLAIN" // Note the use of PLAIN AUTH
    },
}
const transport = nodemailer.createTransport(opts)

CSharp example

using System;
using System.Net;
using System.Net.Mail;
using mailslurp.Api;
using mailslurp.Client;
using mailslurp.Model;
using Xunit;

namespace SmtpService.Tests
{
    public class UnitTest1
    {
        [Fact]
        public void CanSendEmailWithMailSlurpSmtp()
        {
            var apiKey = Environment.GetEnvironmentVariable("API_KEY")
                         ?? throw new ArgumentNullException("Missing API_KEY environment variable containing MailSlurp key");

            // configure client
            var config = new Configuration();
            config.ApiKey.Add("x-api-key", apiKey);
            var inboxController = new InboxControllerApi(config);

            // create an smtp inbox
            var inbox = inboxController.CreateInboxWithOptions(new CreateInboxDto(
                inboxType: CreateInboxDto.InboxTypeEnum.SMTPINBOX
            ));
            Assert.Contains("@mailslurp.mx", inbox.EmailAddress);

            // get smtp host, port, password, username etc
            var imapSmtpAccessDetails = inboxController.GetImapSmtpAccess();
            var smtpClient = new SmtpClient(imapSmtpAccessDetails.SmtpServerHost)
            {
                Port = imapSmtpAccessDetails.SmtpServerPort,
                Credentials = new NetworkCredential(userName: imapSmtpAccessDetails.SmtpUsername, password: imapSmtpAccessDetails.SmtpPassword),
                // disable ssl recommended
                EnableSsl = false
            };
            
            // send email to inbox
            smtpClient.Send(from: "test@external.com", recipients: inbox.EmailAddress, subject: "This inbound", body: "Hello");
            
            // wait for email to arrive
            var waitController = new WaitForControllerApi(config);
            waitController.WaitForLatestEmail(inboxId: inbox.Id, timeout: 30_000);
        }
    }
}

More information