Skip to content

Option B: Send via SMTP

Get your SMTP credentials:

curl https://api.mailerlogic.net/api/v1/smtp-credentials \
  -H "X-API-Key: YOUR_API_KEY"

Node.js Example:

const nodemailer = require('nodemailer');

const transporter = nodemailer.createTransport({
  host: 'smtp.mailerlogic.net',
  port: 587,
  auth: {
    user: 'your-email@example.com',
    pass: 'smtp_password_here'
  }
});

const mailOptions = {
  from: 'sender@mail.yourdomain.com',
  to: 'recipient@example.com',
  subject: 'Hello from MailerLogic!',
  html: '<h1>Hello!</h1><p>Your first email sent via MailerLogic.</p><p><a href="{{unsubscribe}}">Unsubscribe</a></p>',
  text: 'Hello! Your first email sent via MailerLogic.\n\nUnsubscribe: {{unsubscribe}}'
};

transporter.sendMail(mailOptions, (error, info) => {
  if (error) console.log('Error:', error);
  else console.log('Email sent:', info.messageId);
});

Python Example:

import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

msg = MIMEMultipart('alternative')
msg['Subject'] = 'Hello from MailerLogic!'
msg['From'] = 'sender@mail.yourdomain.com'
msg['To'] = 'recipient@example.com'

html = '<h1>Hello!</h1><p>Your first email sent via MailerLogic.</p>'
msg.attach(MIMEText(html, 'html'))

with smtplib.SMTP('smtp.mailerlogic.net', 587) as server:
    server.starttls()
    server.login('your-email@example.com', 'smtp_password_here')
    server.send_message(msg)

PHP Example:

use PHPMailer\PHPMailer\PHPMailer;

$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'smtp.mailerlogic.net';
$mail->SMTPAuth = true;
$mail->Username = 'your-email@example.com';
$mail->Password = 'smtp_password_here';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;

$mail->setFrom('sender@mail.yourdomain.com');
$mail->addAddress('recipient@example.com');
$mail->Subject = 'Hello from MailerLogic!';
$mail->Body = '<h1>Hello!</h1><p>Your first email sent via MailerLogic.</p>';
$mail->isHTML(true);

$mail->send();