Skip to main content

Sending Emails via SMTP

Connect to the Arsel SMTP server from any language or framework that supports SMTP. This page provides setup examples for common environments.

Connection Settings

Use these settings in all examples below:

SettingValue
Hostsmtp.arsel.sa
Port465
SecurityImplicit TLS (SSL)
Auth methodPLAIN or LOGIN
UsernameYour SMTP username (starts with smtp_)
PasswordYour SMTP password (starts with sk_)

Language Examples

Using Nodemailer:

import nodemailer from "nodemailer";

const transporter = nodemailer.createTransport({
host: "smtp.arsel.sa",
port: 465,
secure: true, // implicit TLS
auth: {
user: process.env.ARSEL_SMTP_USERNAME,
pass: process.env.ARSEL_SMTP_PASSWORD,
},
});

const info = await transporter.sendMail({
from: '"My App" <noreply@yourdomain.com>',
to: "user@example.com",
subject: "Welcome to our platform",
html: "<h1>Welcome!</h1><p>Thanks for signing up.</p>",
text: "Welcome! Thanks for signing up.",
});

console.log("Message sent:", info.messageId);

Framework Examples

Add to your settings.py:

EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "smtp.arsel.sa"
EMAIL_PORT = 465
EMAIL_USE_SSL = True
EMAIL_HOST_USER = os.environ["ARSEL_SMTP_USERNAME"]
EMAIL_HOST_PASSWORD = os.environ["ARSEL_SMTP_PASSWORD"]
DEFAULT_FROM_EMAIL = "noreply@yourdomain.com"

Then send emails using Django's built-in functions:

from django.core.mail import send_mail

send_mail(
subject="Welcome to our platform",
message="Welcome! Thanks for signing up.",
html_message="<h1>Welcome!</h1><p>Thanks for signing up.</p>",
from_email=None, # uses DEFAULT_FROM_EMAIL
recipient_list=["user@example.com"],
)

Sending with Attachments

import nodemailer from "nodemailer";
import { readFileSync } from "fs";

const transporter = nodemailer.createTransport({
host: "smtp.arsel.sa",
port: 465,
secure: true,
auth: {
user: process.env.ARSEL_SMTP_USERNAME,
pass: process.env.ARSEL_SMTP_PASSWORD,
},
});

await transporter.sendMail({
from: '"Billing" <billing@yourdomain.com>',
to: "customer@example.com",
subject: "Your invoice for March 2026",
html: "<p>Please find your invoice attached.</p>",
attachments: [
{
filename: "invoice-march-2026.pdf",
content: readFileSync("./invoice.pdf"),
contentType: "application/pdf",
},
],
});

Custom Headers

You can set the analytics category for SMTP emails using the X-Category header:

await transporter.sendMail({
from: "noreply@yourdomain.com",
to: "user@example.com",
subject: "Password Reset",
html: "<p>Click here to reset your password.</p>",
headers: {
"X-Category": "password-reset",
},
});

The X-Category value appears in the API status endpoints and dashboard analytics, letting you filter and group emails by type.


Tracking SMTP Emails

Emails sent via SMTP are tracked the same way as API emails. Use the REST API status endpoints to check delivery:

# List recent emails (includes both API and SMTP emails)
curl "https://api.arsel.sa/v1/email?page=1&limit=10" \
-H "Authorization: Bearer be_your_api_key"

SMTP emails appear with category set to the X-Category header value, or "smtp" if no category header was provided.

Troubleshooting

IssueSolution
Connection refusedVerify your firewall allows outbound traffic on port 465
Authentication failed (535)Check that your credentials are active and not revoked. Verify username starts with smtp_
TLS handshake errorEnsure your client supports TLS 1.2 or higher. Use port 465 with implicit TLS, not STARTTLS
Message rejected (550 Sender ... is not authorized)Verify your sender domain is verified in the Arsel dashboard
Too many messages (421 Too many messages, please slow down)You're exceeding the 2 messages/sec per-organization limit. The server closes the connection — retry on a fresh one. See Handling rate limits.
Monthly sending quota exceeded (451 Monthly sending quota exceeded)You've used your plan's monthly allotment. Upgrade your plan or wait for the next billing period — retrying immediately won't help.