Skip to content

Sending from common stacks

Any SMTP client works. You need four things from your account page: the host, a port, and a login (address and password) made under Settings → Mail logins in your universe. See SMTP and IMAP.

The examples use c1.simmail.dev, port 2525 with STARTTLS, and the login app@yourcompany.test. Port 4650 is the same service with TLS from the first byte.

import nodemailer from "nodemailer";
const transport = nodemailer.createTransport({
host: process.env.SMTP_HOST, // c1.simmail.dev
port: Number(process.env.SMTP_PORT), // 2525
secure: false, // true for port 4650
requireTLS: true, // upgrade with STARTTLS, never send the password in clear
auth: { user: process.env.SMTP_USER, pass: process.env.SMTP_PASS },
});
const info = await transport.sendMail({
from: '"Acme" <app@yourcompany.test>',
to: "dana@harbor.test",
subject: "Your house on Clark Street",
text: "Hi Dana, would you consider an offer of 165,000?",
html: "<p>Hi Dana, would you consider an offer of <b>165,000</b>?</p>",
});
console.log(info.messageId); // use it as in_reply_to when you wait for her reply

If the universe’s certificate is self-signed, either trust it (download it from GET /api/connection/cert and pass it as tls: { ca: [cert] }) or, for a local test rig only, add tls: { rejectUnauthorized: false }.

Wait for the message in a test:

Terminal window
curl -s -G https://c1.simmail.dev/api/wait \
-H "Authorization: Bearer smk_your_key" \
--data-urlencode "to=dana@harbor.test" \
--data-urlencode "subject=Clark Street" \
--data-urlencode "existing=true"

Or open the universe’s dashboard and look under Mail. See the wait API.