Skip to main content

SMTP Code Examples

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

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" <[email protected]>',
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://mail.motorical.com:2587/api/v1/send" \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{
"from": "[email protected]",
"to": ["[email protected]"],
"subject": "Motorical API Key Test",
"text": "Sent via API key authentication!"
}'

mTLS Authentication

# Send with client certificate
curl -X POST "https://api.motorical.com/v1/send" \
--cert your_client.crt \
--key your_client.key \
-H "Content-Type: application/json" \
-d '{
"from": "[email protected]",
"to": ["[email protected]"],
"subject": "mTLS Secured Email",
"text": "Sent using mutual TLS authentication."
}'