Sending Emails
Here's how to connect different frameworks and languages to MailCade.
The key thing: point your app to localhost:1025. No authentication, no encryption.
#Laravel
Add this to your .env file:
MAIL_HOST=localhostMAIL_PORT=1025MAIL_USERNAME=nullMAIL_PASSWORD=nullMAIL_ENCRYPTION=null
Now send an email like normal:
It'll show up in MailCade instead of actually sending.
#Node.js
With Nodemailer:
const nodemailer = require('nodemailer'); const transporter = nodemailer.createTransport({ host: 'localhost', port: 1025}); transporter.sendMail({ subject: 'Test Email', html: '<p>Hello from Node!</p>'});
#Python
Using smtplib:
import smtplibfrom email.mime.text import MIMEText msg = MIMEText('<p>Hello from Python!</p>', 'html')msg['Subject'] = 'Test Email' server = smtplib.SMTP('localhost', 1025)server.send_message(msg)server.quit()
In Django, update your settings.py:
EMAIL_HOST = 'localhost'EMAIL_PORT = 1025EMAIL_USE_TLS = False
Then send emails normally:
from django.core.mail import send_mail send_mail( 'Test Subject', 'Test message.',)
#Ruby on Rails
In config/environments/development.rb:
config.action_mailer.smtp_settings = { address: 'localhost', port: 1025}
Then send emails as usual:
UserMailer.welcome_email(@user).deliver_now
#PHP
ini_set('SMTP', 'localhost');ini_set('smtp_port', 1025); mail( 'Test Email', 'Hello from PHP!', 'From: [email protected]');
#Go
package main import "net/smtp" func main() { msg := []byte("Subject: Test\r\n\r\nHello from Go!") smtp.SendMail("localhost:1025", nil, from, to, msg)}
#Java
With JavaMail:
Properties props = new Properties();props.put("mail.smtp.host", "localhost");props.put("mail.smtp.port", "1025"); Session session = Session.getInstance(props);Message message = new MimeMessage(session);message.setRecipients(Message.RecipientType.TO,message.setSubject("Test Email");message.setText("Hello from Java!"); Transport.send(message);
#Quick test with cURL
Want to test without writing code? Use curl:
curl smtp://localhost:1025 \ --upload-file - <<EOFSubject: Test from cURL If you see this, it works!EOF
#From Docker containers
If your app runs in Docker, localhost won't work. Use host.docker.internal instead:
# docker-compose.ymlenvironment: MAIL_HOST: host.docker.internal MAIL_PORT: 1025
On Linux, add this too:
extra_hosts: - "host.docker.internal:host-gateway"
#Troubleshooting
Emails not showing up? Check these:
- Make sure MailCade is running (sidebar shows "● Running")
- Double-check you're using
localhost:1025 - Turn off TLS/SSL in your app config
- Turn off SMTP authentication
- Try the curl command above to isolate the issue
Still stuck? The troubleshooting guide has more solutions.
#What's next
Now that emails are flowing in, learn how to inspect them or check out testing workflows for specific scenarios like password resets.