Skip to main content

SMTP Code Examples

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

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

Basic Authentication

const nodemailer = require('nodemailer');

const transporter = nodemailer.createTransporter({
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",
"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",
"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.