Python
smtplib is in the standard library — nothing to install.
Prerequisites
- Python 3.6 or later
1Send a test message
import smtplib from email.message import EmailMessage message = EmailMessage() message['From'] = 'staging@example.com' message['To'] = 'anyone@example.com' message['Subject'] = 'Sandbox check' message.set_content('Hello from Python.') with smtplib.SMTP('smtp.mailclutch.com', 587) as smtp: smtp.starttls() smtp.login('mc_0000000000000000', 'pw_0000000000000000') smtp.send_message(message)
starttls() before login(): the credentials must not leave the process in the clear, and the server refuses AUTH before the upgrade.
2Or on port 465
with smtplib.SMTP_SSL('smtp.mailclutch.com', 465) as smtp: smtp.login('mc_0000000000000000', 'pw_0000000000000000') smtp.send_message(message)
Watch it land
Open the sandbox and the message is there — rendered HTML, plain text, raw source, attachments, and the SPF, DKIM and DMARC verdicts. It updates live, so you can leave it open next to your terminal.
Nothing is ever delivered onward, whatever address you send to; claim the sandbox with an account and it stays.
Awaiting your email
Send from any address; it stops here rather than going onward. The sandbox keeps what it catches for 24 hours.
Go further
Connection timeout
smtplib.SMTPwaits on a blocked port until its timeout. If 587 is filtered on your network, use 2525 with the samestarttls()call, orSMTP_SSLon 465.Flask, FastAPI, Celery
Anything built on
smtplibtakes the same four values. In Flask-Mail they areMAIL_SERVER,MAIL_PORT,MAIL_USERNAME,MAIL_PASSWORD, plusMAIL_USE_TLS = True.
Other stacks
The same four values in another dialect. Every guide below is filled in with the sandbox pair at the top of this page.
Frameworks and languages
- LaravelFive .env variables, no package
- SymfonyOne MAILER_DSN
- DjangoFive settings, nothing installed
- RailsAction Mailer smtp_settings
- Node.jsA Nodemailer transport
- Next.jsRoute Handler or Server Action
- Gonet/smtp, standard library
- SpringFive Spring Boot properties
- JavaJakarta Mail, no framework
- .NETMailKit: connect, auth, send
- PHPPHPMailer, no framework
- Rustlettre over a STARTTLS relay