Skip to main content
About this page ยท Updated 2026-10-20 19:24 UTC

What this page is: SMTP integration examples in multiple languages for sending messages, attachments, and secure authenticated traffic.

How far to trust this page: the build checked 4 names, paths, tools, scopes and error codes against the real product (0 do not match). Names, paths and numbers checked on 2026-10-22; behaviour prose not verified claim by claim.

Updated 2026-10-20 19:24 UTCRecently updated pages

SMTP Code Examples

Complete, copy-paste-ready code examples for integrating Motorical SMTP into your application.

Sending a file? See Send attachments for working examples, the size ceiling and the exact errors.

For runnable projects, see the Motorical SMTP GitHub examples, especially the SMTP Nodemailer example.

:::tip Friendly From on SMTP vs HTTP SMTP submission uses the message From: header โ€” e.g. From: "Acme Billing" <sender@yourdomain.com>. Motorical preserves that display name through signing. HTTP POST /v1/send uses a separate JSON field fromName instead (a From custom header is rejected). :::

Basic Authenticationโ€‹

const nodemailer = require('nodemailer');

const transporter = nodemailer.createTransport({
host: 'mail.motorical.com',
port: 2587,
secure: false,
auth: {
user: 'your_motor_block_username',
pass: 'your_motor_block_password'
},
tls: {
rejectUnauthorized: true
}
});

async function sendEmail() {
try {
const info = await transporter.sendMail({
from: '"Your Name" <username@your-domain.com>',
to: 'recipient@example.com',
subject: 'Hello from Motorical SMTP!',
text: 'This is a test email sent via Motorical SMTP.',
html: '<h1>Hello!</h1><p>Sent via <strong>Motorical SMTP</strong>.</p>'
});
console.log('Email sent:', info.messageId);
} catch (error) {
console.error('Error:', error);
}
}

sendEmail();

API Key Authentication (HTTP API)โ€‹

curl -X POST "https://api.motorical.com/v1/send" \
-H "Authorization: ApiKey mk_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "sender@yourdomain.com",
"fromName": "Acme Billing",
"to": ["recipient@example.com"],
"subject": "Motorical SMTP API Key Test",
"text": "Sent via API key authentication!",
"html": "<p>Sent via API key authentication!</p>"
}'

You can also use the X-Api-Key header instead of Authorization: ApiKey ....

To validate the same request without sending or creating an email log, include dryRun: true:

curl -X POST "https://api.motorical.com/v1/send" \
-H "Authorization: ApiKey mk_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "sender@yourdomain.com",
"fromName": "Acme Billing",
"to": ["recipient@example.com"],
"subject": "Motorical SMTP dry-run test",
"text": "Validate this payload without queueing it.",
"dryRun": true
}'

SMTP Setup Test Endpointโ€‹

Use this endpoint to validate SMTP setup parameters from onboarding or diagnostics tooling. It uses the same Motorical SMTP Motor Block API Key authentication as /v1/send.

curl -X POST "https://api.motorical.com/v1/test-email" \
-H "Authorization: ApiKey mk_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"method": "starttls",
"host": "mail.motorical.com",
"port": 2587,
"username": "your_motor_block_username",
"password": "your_motor_block_password",
"to": "recipient@example.com",
"subject": "Motorical SMTP setup test",
"requireTLS": true
}'

mTLS Authenticationโ€‹

mTLS is not currently a supported authentication method for the public HTTP Send API. Use a Motorical SMTP Motor Block API Key with Authorization: ApiKey mk_live_... or X-Api-Key: mk_live_... for POST https://api.motorical.com/v1/send.

If your integration requires certificate-based transport controls, contact support before building against it so we can confirm the correct production setup for your account.