Sendpit Integration Guide
Introduction
Sendpit is an email testing platform that captures outgoing emails from your application during development and QA. It provides isolated SMTP mailboxes so you can test email functionality without sending messages to real recipients.
Sendpit integrates using standard SMTP configuration. No SDKs or APIs are required.
SMTP Credentials
Each Sendpit mailbox provides unique SMTP credentials:
| Setting | Value |
|---|---|
| Host | smtp.sendpit.com |
| Port | 1025, 587, or 2525 |
| Username | mb_xxxxxxxxxxxxxxxx (unique per mailbox) |
| Password | 32-character string (unique per mailbox) |
| Encryption | STARTTLS (required) |
Environment Variable Convention
SMTP_HOST=smtp.sendpit.com
SMTP_PORT=1025
SMTP_USERNAME=mb_xxxxxxxxxxxxxxxx
SMTP_PASSWORD=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Credentials are available in your Sendpit dashboard under Mailbox → Settings → SMTP Credentials.
Quick Start (Generic SMTP)
Configure any application or library that supports SMTP with these settings:
Host: smtp.sendpit.com
Port: 1025 (or 587, 2525)
Username: <your mailbox username>
Password: <your mailbox password>
Encryption: STARTTLS
Auth: Plain
Send a test email using your application's normal email functionality. The message appears in your Sendpit mailbox within seconds.
Language-Specific Integration
PHP (Laravel)
.env
MAIL_MAILER=smtp
MAIL_HOST=smtp.sendpit.com
MAIL_PORT=1025
MAIL_USERNAME=mb_xxxxxxxxxxxxxxxx
MAIL_PASSWORD=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME="${APP_NAME}"
config/mail.php (default Laravel config works)
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.sendpit.com'),
'port' => env('MAIL_PORT', 1025),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
],
Sending mail
use Illuminate\Support\Facades\Mail;
Mail::raw('Test email body', function ($message) {
$message->to('[email protected]')
->subject('Test from Sendpit');
});
Node.js (Nodemailer)
Install
npm install nodemailer
.env
SMTP_HOST=smtp.sendpit.com
SMTP_PORT=1025
SMTP_USERNAME=mb_xxxxxxxxxxxxxxxx
SMTP_PASSWORD=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
send-email.js
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
host: process.env.SMTP_HOST,
port: parseInt(process.env.SMTP_PORT, 10),
secure: false, // Use STARTTLS
requireTLS: true, // Require STARTTLS upgrade
auth: {
user: process.env.SMTP_USERNAME,
pass: process.env.SMTP_PASSWORD,
},
});
async function sendTestEmail() {
const info = await transporter.sendMail({
from: '"Test App" <[email protected]>',
to: '[email protected]',
subject: 'Test from Sendpit',
text: 'This is a test email.',
html: '<p>This is a test email.</p>',
});
console.log('Message sent:', info.messageId);
}
sendTestEmail().catch(console.error);
Python (smtplib)
.env
SMTP_HOST=smtp.sendpit.com
SMTP_PORT=1025
SMTP_USERNAME=mb_xxxxxxxxxxxxxxxx
SMTP_PASSWORD=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
send_email.py
import os
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
smtp_host = os.environ['SMTP_HOST']
smtp_port = int(os.environ['SMTP_PORT'])
smtp_user = os.environ['SMTP_USERNAME']
smtp_pass = os.environ['SMTP_PASSWORD']
msg = MIMEMultipart('alternative')
msg['Subject'] = 'Test from Sendpit'
msg['From'] = '[email protected]'
msg['To'] = '[email protected]'
text = 'This is a test email.'
html = '<p>This is a test email.</p>'
msg.attach(MIMEText(text, 'plain'))
msg.attach(MIMEText(html, 'html'))
with smtplib.SMTP(smtp_host, smtp_port) as server:
server.starttls() # Upgrade to TLS
server.login(smtp_user, smtp_pass)
server.sendmail(msg['From'], msg['To'], msg.as_string())
print('Email sent successfully')
Ruby (Action Mailer / Rails)
config/environments/development.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: ENV['SMTP_HOST'],
port: ENV['SMTP_PORT'].to_i,
user_name: ENV['SMTP_USERNAME'],
password: ENV['SMTP_PASSWORD'],
authentication: :plain,
enable_starttls_auto: true
}
.env
SMTP_HOST=smtp.sendpit.com
SMTP_PORT=1025
SMTP_USERNAME=mb_xxxxxxxxxxxxxxxx
SMTP_PASSWORD=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
app/mailers/test_mailer.rb
class TestMailer < ApplicationMailer
def test_email
mail(
to: '[email protected]',
subject: 'Test from Sendpit',
body: 'This is a test email.'
)
end
end
Send from console
TestMailer.test_email.deliver_now
Ruby (Net::SMTP standalone)
require 'net/smtp'
smtp_host = ENV['SMTP_HOST']
smtp_port = ENV['SMTP_PORT'].to_i
smtp_user = ENV['SMTP_USERNAME']
smtp_pass = ENV['SMTP_PASSWORD']
message = <<~MESSAGE
From: [email protected]
To: [email protected]
Subject: Test from Sendpit
This is a test email.
MESSAGE
smtp = Net::SMTP.new(smtp_host, smtp_port)
smtp.enable_starttls # Enable STARTTLS
smtp.start('localhost', smtp_user, smtp_pass, :plain) do |server|
server.send_message(message, '[email protected]', '[email protected]')
end
puts 'Email sent successfully'
Java (Jakarta Mail)
pom.xml
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>2.0.1</version>
</dependency>
SendEmail.java
import jakarta.mail.*;
import jakarta.mail.internet.*;
import java.util.Properties;
public class SendEmail {
public static void main(String[] args) {
String host = System.getenv("SMTP_HOST");
String port = System.getenv("SMTP_PORT");
String username = System.getenv("SMTP_USERNAME");
String password = System.getenv("SMTP_PASSWORD");
Properties props = new Properties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.port", port);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.starttls.required", "true");
Session session = Session.getInstance(props, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("[email protected]"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("[email protected]"));
message.setSubject("Test from Sendpit");
message.setText("This is a test email.");
Transport.send(message);
System.out.println("Email sent successfully");
} catch (MessagingException e) {
throw new RuntimeException(e);
}
}
}
Go (net/smtp)
main.go
package main
import (
"crypto/tls"
"fmt"
"net"
"net/smtp"
"os"
)
func main() {
host := os.Getenv("SMTP_HOST")
port := os.Getenv("SMTP_PORT")
username := os.Getenv("SMTP_USERNAME")
password := os.Getenv("SMTP_PASSWORD")
from := "[email protected]"
to := "[email protected]"
msg := []byte("To: [email protected]\r\n" +
"Subject: Test from Sendpit\r\n" +
"\r\n" +
"This is a test email.\r\n")
// Connect to server
conn, err := net.Dial("tcp", host+":"+port)
if err != nil {
fmt.Printf("Connection error: %v\n", err)
return
}
client, err := smtp.NewClient(conn, host)
if err != nil {
fmt.Printf("Client error: %v\n", err)
return
}
defer client.Close()
// Upgrade to TLS (STARTTLS)
tlsConfig := &tls.Config{ServerName: host}
if err = client.StartTLS(tlsConfig); err != nil {
fmt.Printf("STARTTLS error: %v\n", err)
return
}
// Authenticate
auth := smtp.PlainAuth("", username, password, host)
if err = client.Auth(auth); err != nil {
fmt.Printf("Auth error: %v\n", err)
return
}
// Send email
if err = client.Mail(from); err != nil {
fmt.Printf("Mail error: %v\n", err)
return
}
if err = client.Rcpt(to); err != nil {
fmt.Printf("Rcpt error: %v\n", err)
return
}
w, err := client.Data()
if err != nil {
fmt.Printf("Data error: %v\n", err)
return
}
_, err = w.Write(msg)
if err != nil {
fmt.Printf("Write error: %v\n", err)
return
}
err = w.Close()
if err != nil {
fmt.Printf("Close error: %v\n", err)
return
}
client.Quit()
fmt.Println("Email sent successfully")
}
.env (load with godotenv or export manually)
SMTP_HOST=smtp.sendpit.com
SMTP_PORT=1025
SMTP_USERNAME=mb_xxxxxxxxxxxxxxxx
SMTP_PASSWORD=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Common SMTP Errors & Troubleshooting
Authentication Failed
535 5.7.8 Authentication credentials invalid
Causes:
- Incorrect username or password
- Credentials copied with trailing whitespace
- Mailbox deleted or credentials regenerated
Fix:
- Re-copy credentials from the Sendpit dashboard
- Verify no extra spaces in
.envfile - Check that the mailbox still exists
Connection Refused
Connection refused (port 1025)
Causes:
- Firewall blocking outbound port 1025
- Corporate network restrictions
- Incorrect host or port
Fix:
- Verify
smtp.sendpit.com:1025is reachable:telnet smtp.sendpit.com 1025 - Contact your network administrator if port 1025 is blocked
- Some corporate networks require VPN or allowlisting
TLS/SSL Errors
SSL routines:ssl3_get_record:wrong version number
Causes:
- Using implicit TLS (port 465) instead of STARTTLS
- TLS configuration mismatch
Fix:
- Use STARTTLS encryption (not implicit SSL/TLS)
- Use port
1025,587, or2525 - Ensure
secure: falsewithrequireTLS: truein Node.js (Nodemailer) - Sendpit requires STARTTLS—authentication happens after the TLS upgrade
Connection Timeout
Connection timed out after 30 seconds
Causes:
- Network latency or routing issues
- DNS resolution problems
- Firewall silently dropping packets
Fix:
- Test connectivity:
nc -zv smtp.sendpit.com 1025 - Try from a different network
- Check DNS resolution:
nslookup smtp.sendpit.com
Rate Limiting
Sendpit does not enforce strict rate limits on SMTP connections, but fair use applies. If you're sending thousands of emails in a short period during testing, you may experience delays.
Best practice: Space out bulk test sends or use multiple mailboxes for parallel test suites.
Security & Best Practices
Keep Credentials in Environment Variables
Never hardcode SMTP credentials in source code.
// Bad
$password = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
// Good
$password = env('MAIL_PASSWORD');
Use .env Files (Not Committed to Git)
# .gitignore
.env
.env.local
.env.*.local
Rotate Credentials Periodically
Regenerate SMTP credentials in the Sendpit dashboard if:
- A team member leaves
- Credentials may have been exposed
- As part of regular security hygiene
Regenerating credentials immediately invalidates the old password.
Use Separate Mailboxes per Environment
| Environment | Mailbox |
|---|---|
| Local dev | Dev - Local |
| CI/CD | CI Pipeline |
| Staging | Staging |
This prevents test data from mixing and simplifies debugging.
Avoid Logging Credentials
Ensure your logging configuration does not output SMTP passwords:
// Laravel: config/logging.php
'redact' => ['password', 'MAIL_PASSWORD'],
What Sendpit Does Not Do
Sendpit is intentionally focused on SMTP-based email capture. The following are not supported:
| Feature | Status |
|---|---|
| REST API for email retrieval | Not available |
| Official SDKs or client libraries | Not available |
| POP3/IMAP access | Not available |
| Programmatic mailbox management | Not available |
Integration is done exclusively via SMTP. Access captured emails through the Sendpit web dashboard.
Next Steps: Webhook Automation
Once SMTP integration is working, you can automate workflows using webhooks (Pro plans and above).
Webhooks notify your application in real-time when emails arrive—useful for:
- CI/CD pipelines that verify email delivery
- Automated QA workflows
- Custom integrations and alerting
Learn more: Developer Documentation → Webhooks
Quick Connectivity Test
Before troubleshooting application issues, verify basic connectivity:
# Test TCP connection
nc -zv smtp.sendpit.com 1025
# Test with telnet (interactive)
telnet smtp.sendpit.com 1025
# Test DNS resolution
nslookup smtp.sendpit.com
# Test with OpenSSL (if TLS issues suspected)
openssl s_client -connect smtp.sendpit.com:1025 -starttls smtp
If these commands fail, the issue is network-level (firewall, DNS, routing), not application configuration.
Last updated: December 2025