SMTP Email Sender: Send Emails via SMTP with Code, Dashboard, or API

Learn every method for sending emails through SMTP, from web dashboards and command-line tools to code examples in Node.js, Python, PHP, Ruby, and Go. Understand SMTP commands, track deliveries, and troubleshoot sending errors.

What Is an SMTP Email Sender

An SMTP email sender is any tool, application, or script that connects to an SMTP server to transmit email messages. The term encompasses a broad range of sending methods: web-based dashboards where you compose and send emails through a browser interface, command-line tools that send emails from a terminal, programming libraries that integrate SMTP sending into your application code, and desktop email clients like Thunderbird or Outlook that use SMTP for outgoing mail.

At its core, every SMTP email sender performs the same sequence of operations. It establishes a TCP connection to an SMTP server, authenticates with credentials, specifies the sender and recipient addresses, transmits the message content including headers and body, and closes the connection. The difference between sending methods lies in the interface exposed to the user and the level of control over the underlying SMTP conversation.

A web dashboard provides the simplest experience: you fill in fields and click send, and the dashboard handles all SMTP protocol details behind the scenes. A programming library like Nodemailer or PHPMailer provides a high-level API that abstracts SMTP commands into method calls while still giving you control over headers, content types, and connection parameters. A raw SMTP session via telnet or openssl gives you direct access to every SMTP command, which is useful for testing and debugging but impractical for production sending.

QUEENSMTP supports all of these sending methods. You can send emails through our web dashboard for one-off messages and testing, through SMTP relay for application integration, and through our RESTful API for programmatic sending. Every method uses the same underlying SMTP service infrastructure, which means your emails benefit from the same dedicated IP addresses, authentication, and deliverability optimization regardless of how you send them.

Different Ways to Send Emails via SMTP

Understanding the available sending methods helps you choose the right approach for your use case. Here is an overview of the five primary ways to send emails through SMTP, along with when each method is most appropriate.

💻

Web Dashboard

Compose and send emails through a browser-based interface. Best for testing, one-off messages, and non-technical users who need to send occasional emails without writing code or configuring software.

🔌

API Integration

Send emails programmatically through a RESTful API using HTTP requests. Best for modern applications that prefer HTTP over SMTP, need JSON payloads, and want simplified error handling with standard HTTP status codes.

📝

SMTP Relay

Configure your application, CMS, or email client to connect directly to the SMTP server using standard credentials. Best for WordPress, existing applications, and any system that already supports SMTP configuration.

Command Line

Send emails from a terminal using tools like swaks, curl, or openssl. Best for scripting, automation, cron jobs, server monitoring alerts, and testing SMTP connectivity from specific environments.

🛠

Programming Libraries

Use language-specific SMTP libraries like Nodemailer (Node.js), smtplib (Python), or PHPMailer (PHP). Best for custom applications that need fine-grained control over email composition and delivery.

Sending from the QUEENSMTP Web Dashboard

The QUEENSMTP web dashboard includes a built-in email sender tool that lets you compose and send emails directly from your browser. This is the fastest way to send a test email, verify your SMTP configuration, or send a one-off message without writing any code.

To send an email from the dashboard, log in to your QUEENSMTP account and navigate to the "Send Email" section. You will see a form with the following fields: From address (pre-populated with your authenticated domain), To address (one or multiple recipients), Subject line, and a content editor that supports both plain text and HTML. The HTML editor includes a rich text toolbar for formatting, or you can switch to source mode and paste your own HTML code directly.

After composing your email, click "Send" to deliver the message immediately. The dashboard shows real-time delivery status: queued, sent, delivered, or failed. If the message fails, the specific SMTP error code and reason are displayed so you can diagnose the issue. For delivered messages, you can track opens and clicks directly from the message detail view.

The dashboard sender is also useful for testing email templates before deploying them in your application. Paste your HTML template into the source editor, send it to your own address, and verify the rendering across different email clients. This eliminates the need for a separate testing workflow during template development.

Sending HTML Emails via SMTP

HTML emails allow you to include formatted text, images, buttons, and custom layouts that plain text cannot provide. Sending HTML email via SMTP requires setting the correct Content-Type header and ensuring your HTML is compatible with email client rendering engines, which are significantly more limited than web browsers.

The key header for HTML email is Content-Type: text/html; charset=UTF-8. This tells the receiving email client to render the message body as HTML rather than displaying it as plain text. Most SMTP libraries set this header automatically when you specify HTML content, but understanding the underlying mechanism helps when troubleshooting rendering issues.

Email HTML is not the same as web HTML. Email clients like Outlook, Gmail, and Apple Mail each have their own rendering engines with significant CSS limitations. Outlook uses the Microsoft Word rendering engine, which does not support modern CSS properties like flexbox, grid, or CSS animations. Gmail strips certain CSS selectors and does not support embedded style sheets in the head element. For reliable cross-client rendering, email HTML should use table-based layouts, inline CSS styles, and HTML attributes for spacing and alignment.

Here are the key rules for HTML email that renders consistently across all major email clients: use table-based layouts instead of div-based layouts, inline all CSS rather than using external or embedded style sheets, use absolute URLs for all images, set explicit width and height attributes on images, use web-safe fonts with fallbacks, test with a 600-pixel maximum width for the email body, and avoid JavaScript entirely as it is stripped by all email clients.

Sending with Code: Multi-Language Examples

Integrating SMTP email sending into your application is straightforward with the right library. Below are complete, working code examples for the five most popular server-side languages, all configured to send through QUEENSMTP.

Node.js with Nodemailer

Nodemailer is the standard email library for Node.js, with over 14 million weekly downloads on npm. It supports SMTP, connection pooling, HTML content, attachments, and DKIM signing.

// npm install nodemailer
const nodemailer = require('nodemailer');

const transporter = nodemailer.createTransport({
    host: 'smtp.queensmtp.com',
    port: 587,
    secure: false, // true for 465, false for 587 (STARTTLS)
    auth: {
        user: 'your-smtp-username',
        pass: 'your-smtp-api-key'
    },
    pool: true,        // Enable connection pooling for bulk sends
    maxConnections: 5, // Max simultaneous connections
    maxMessages: 100   // Max messages per connection
});

async function sendEmail() {
    const info = await transporter.sendMail({
        from: '"Your Business" <hello@yourdomain.com>',
        to: 'recipient@example.com',
        subject: 'Welcome to Our Platform',
        text: 'Plain text version of the email for clients that do not render HTML.',
        html: `
            <div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
                <h1 style="color: #333;">Welcome!</h1>
                <p style="color: #666; line-height: 1.6;">
                    Thank you for signing up. Click the button below to verify your account.
                </p>
                <a href="https://yourdomain.com/verify?token=abc123"
                   style="display: inline-block; padding: 12px 24px; background: #007bff;
                          color: #fff; text-decoration: none; border-radius: 4px;">
                    Verify Email
                </a>
            </div>
        `,
        headers: {
            'X-Custom-Header': 'my-app-v2',
            'List-Unsubscribe': '<https://yourdomain.com/unsubscribe?id=123>'
        }
    });

    console.log('Message sent:', info.messageId);
    console.log('Accepted:', info.accepted);
    console.log('Rejected:', info.rejected);
}

sendEmail().catch(console.error);

Python with smtplib

Python's built-in smtplib module provides SMTP client functionality without any external dependencies. For HTML emails with attachments, combine it with the email.mime modules from the standard library.

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

def send_email():
    # Create multipart message (HTML + plain text fallback)
    msg = MIMEMultipart('alternative')
    msg['From'] = 'Your Business <hello@yourdomain.com>'
    msg['To'] = 'recipient@example.com'
    msg['Subject'] = 'Welcome to Our Platform'
    msg['Reply-To'] = 'support@yourdomain.com'

    # Plain text version
    text = "Welcome! Thank you for signing up. Visit https://yourdomain.com/verify to verify."

    # HTML version
    html = """
    <div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto;">
        <h1 style="color: #333;">Welcome!</h1>
        <p style="color: #666; line-height: 1.6;">
            Thank you for signing up. Click below to verify your account.
        </p>
        <a href="https://yourdomain.com/verify?token=abc123"
           style="display: inline-block; padding: 12px 24px; background: #007bff;
                  color: #fff; text-decoration: none; border-radius: 4px;">
            Verify Email
        </a>
    </div>
    """

    msg.attach(MIMEText(text, 'plain'))
    msg.attach(MIMEText(html, 'html'))

    # Connect and send via QUEENSMTP
    with smtplib.SMTP('smtp.queensmtp.com', 587) as server:
        server.starttls()
        server.login('your-smtp-username', 'your-smtp-api-key')
        server.send_message(msg)
        print('Email sent successfully')

send_email()

PHP with PHPMailer

PHPMailer is the most widely used email library for PHP, powering the email functionality of WordPress, Drupal, and thousands of custom applications. It provides a clean object-oriented interface for SMTP sending.

// composer require phpmailer/phpmailer
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

require 'vendor/autoload.php';

$mail = new PHPMailer(true);

try {
    // SMTP configuration
    $mail->isSMTP();
    $mail->Host       = 'smtp.queensmtp.com';
    $mail->SMTPAuth   = true;
    $mail->Username   = 'your-smtp-username';
    $mail->Password   = 'your-smtp-api-key';
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
    $mail->Port       = 587;

    // Sender and recipient
    $mail->setFrom('hello@yourdomain.com', 'Your Business');
    $mail->addReplyTo('support@yourdomain.com', 'Support');
    $mail->addAddress('recipient@example.com', 'Recipient Name');

    // Content
    $mail->isHTML(true);
    $mail->Subject = 'Welcome to Our Platform';
    $mail->Body    = '<h1>Welcome!</h1><p>Thank you for signing up.</p>';
    $mail->AltBody = 'Welcome! Thank you for signing up.';

    $mail->send();
    echo 'Email sent successfully';
} catch (Exception $e) {
    echo "Failed to send: {$mail->ErrorInfo}";
}

Ruby with Net::SMTP

Ruby includes Net::SMTP in its standard library for basic SMTP sending. For more complex emails with HTML, attachments, and multipart content, the Mail gem provides a higher-level interface.

# gem install mail
require 'mail'

Mail.defaults do
  delivery_method :smtp, {
    address:              'smtp.queensmtp.com',
    port:                 587,
    user_name:            'your-smtp-username',
    password:             'your-smtp-api-key',
    authentication:       :plain,
    enable_starttls_auto: true
  }
end

mail = Mail.new do
  from    'Your Business <hello@yourdomain.com>'
  to      'recipient@example.com'
  subject 'Welcome to Our Platform'

  text_part do
    body 'Welcome! Thank you for signing up.'
  end

  html_part do
    content_type 'text/html; charset=UTF-8'
    body '<h1>Welcome!</h1><p>Thank you for signing up.</p>'
  end
end

mail.deliver!
puts "Email sent: #{mail.message_id}"

Go with net/smtp

Go's standard library includes the net/smtp package for SMTP sending. For production applications, the gomail package provides a more ergonomic interface with support for attachments and HTML content.

package main

import (
    "fmt"
    "net/smtp"
    "strings"
)

func main() {
    // QUEENSMTP SMTP credentials
    host := "smtp.queensmtp.com"
    port := "587"
    user := "your-smtp-username"
    pass := "your-smtp-api-key"

    from := "hello@yourdomain.com"
    to := []string{"recipient@example.com"}

    // Compose email with headers
    headers := make(map[string]string)
    headers["From"] = "Your Business <" + from + ">"
    headers["To"] = strings.Join(to, ", ")
    headers["Subject"] = "Welcome to Our Platform"
    headers["MIME-Version"] = "1.0"
    headers["Content-Type"] = "text/html; charset=UTF-8"

    body := "<h1>Welcome!</h1><p>Thank you for signing up.</p>"

    // Build message
    msg := ""
    for k, v := range headers {
        msg += k + ": " + v + "\r\n"
    }
    msg += "\r\n" + body

    // Authenticate and send
    auth := smtp.PlainAuth("", user, pass, host)
    err := smtp.SendMail(host+":"+port, auth, from, to, []byte(msg))
    if err != nil {
        fmt.Printf("Error: %v\n", err)
        return
    }
    fmt.Println("Email sent successfully")
}

SMTP vs API Sending Comparison

Modern email service providers like QUEENSMTP offer two primary methods for programmatic email sending: SMTP relay and RESTful API. Both methods deliver email through the same infrastructure, but they differ in protocol, integration complexity, and feature access. Understanding the tradeoffs helps you choose the right method for your application.

Aspect SMTP Relay REST API
Protocol SMTP (TCP port 587/465) HTTPS (port 443)
Authentication Username + password (SMTP AUTH) API key (HTTP header)
Payload Format MIME-encoded email JSON object
Connection Model Persistent TCP connection (poolable) Stateless HTTP requests
Firewall Compatibility May be blocked on ports 587/465 Almost never blocked (HTTPS)
Bulk Sending Speed Fast with connection pooling Fast with concurrent requests
Error Handling SMTP status codes (250, 550, etc.) HTTP status codes (200, 400, etc.)
Template Support Client-side rendering only Server-side template rendering
Integration Effort Low (most apps already support SMTP) Moderate (requires API client code)
Best For WordPress, legacy apps, CMS platforms Modern apps, microservices, serverless

Choose SMTP relay when your application already has SMTP configuration built in, such as WordPress, Magento, WooCommerce, or legacy applications. SMTP relay requires minimal code changes because you are simply providing server credentials rather than integrating a new API. SMTP is also the better choice when you need connection pooling for high-throughput sending, because a single persistent SMTP connection can transmit hundreds of messages without the overhead of establishing new HTTP connections for each send.

Choose API sending when you are building a new application, working in a serverless environment like AWS Lambda or Cloudflare Workers, or need server-side template rendering. APIs use HTTPS, which is almost never blocked by firewalls, making them more reliable in restrictive network environments. API responses return structured JSON with detailed error information, which is easier to parse and handle than SMTP status codes. QUEENSMTP's API also supports batch sending, where you can submit multiple recipients in a single request and receive individual delivery status for each.

Sending Bulk Emails via SMTP Properly

Sending bulk email through SMTP requires careful attention to connection management, throttling, and deliverability best practices. For high-volume campaigns, consider using a dedicated bulk email service with built-in list management. Sending thousands of emails carelessly can damage your sender reputation, trigger rate limits, and result in emails being blocked or filtered to spam. Here are the essential practices for bulk SMTP sending.

Connection Pooling

Opening a new SMTP connection for every email is wasteful and slow. Each connection requires TCP handshake, TLS negotiation, and authentication, which adds 200-500 milliseconds of overhead per message. For bulk sending, use connection pooling to reuse SMTP connections across multiple messages. Most SMTP libraries support this natively. In Nodemailer, set pool: true in the transporter options. In Python, keep the smtplib connection open and call send_message() repeatedly before calling quit().

Throttling and Rate Limiting

Even with a dedicated IP and proper authentication, sending too many emails too fast can trigger receiving server defenses. ISPs like Gmail, Yahoo, and Outlook monitor incoming email velocity and will temporarily defer or reject messages if the rate exceeds their thresholds. QUEENSMTP's outbound queue handles rate limiting automatically, distributing your messages at optimal speeds for each receiving domain. However, your application should still implement sensible sending rates: avoid bursting thousands of emails in seconds, and spread large campaigns over minutes or hours.

Recipient List Hygiene

Before sending a bulk campaign, validate your recipient list. Remove addresses that have previously bounced, unsubscribed, or marked your messages as spam. Sending to invalid addresses generates hard bounces that damage your sender reputation. Sending to addresses that have complained leads to ISP complaints that can get your IP blacklisted. QUEENSMTP provides automatic bounce suppression, which prevents you from sending to addresses that have bounced in the past, but cleaning your list before sending is still best practice.

Personalization and Individual Sending

For bulk email, send each message individually rather than using BCC or multiple RCPT TO commands for the same message. Individual sending allows you to personalize the subject line, greeting, and content for each recipient, which improves engagement rates and reduces spam complaints. It also prevents a single bounce or complaint from affecting the delivery of other messages in the same batch. Most email sending libraries support batch processing with per-recipient personalization.

Tracking Sent Emails: Delivery, Opens, and Clicks

Sending an email is only half the story. Understanding what happens after you send is essential for optimizing your email program and diagnosing delivery issues. QUEENSMTP provides comprehensive event tracking for every email sent through the platform.

Delivery tracking tells you whether the receiving mail server accepted your message. A "delivered" status means the message was accepted by the recipient's mail server and placed in their mailbox. This does not guarantee inbox placement because the receiving server may still route the message to the spam folder, but it confirms successful transmission. QUEENSMTP tracks delivery events in real time and makes them available through the dashboard and webhooks.

Bounce tracking records messages that were rejected by the receiving server. Hard bounces indicate permanent failures, such as invalid email addresses or non-existent domains. Soft bounces indicate temporary failures, such as a full mailbox or a temporarily unavailable server. QUEENSMTP automatically categorizes bounces and adds hard-bounce addresses to your suppression list to prevent repeat sends.

Open tracking works by inserting a tiny transparent tracking pixel image into the HTML body of your email. When the recipient opens the email and their client loads images, the pixel is requested from QUEENSMTP's tracking server, which records the open event along with the timestamp, IP address, and user agent. Open tracking is not 100% accurate because some email clients block image loading by default, and privacy features in Apple Mail and Gmail can pre-fetch images, but it provides useful directional data for measuring engagement.

Click tracking replaces links in your email with tracking URLs that redirect through QUEENSMTP's click tracking server before forwarding the recipient to the original destination. This records which links were clicked, when, and by whom. Click tracking provides more reliable engagement data than open tracking because it requires an active user action rather than passive image loading.

Complaint tracking records when recipients mark your email as spam using the "Report Spam" button in their email client. QUEENSMTP participates in feedback loops with major ISPs, which means we receive complaint notifications and can relay them to you via webhooks. High complaint rates are the fastest way to damage your sender reputation, so monitoring and acting on complaints is critical.

SMTP Commands Explained

Understanding SMTP commands helps you debug sending issues, interpret server logs, and understand what happens during the SMTP conversation. Here is a walkthrough of a complete SMTP session with annotations explaining each command and response.

// Connect to QUEENSMTP on port 587
$ openssl s_client -connect smtp.queensmtp.com:587 -starttls smtp

// Server greeting
220 smtp.queensmtp.com ESMTP ready

// Client introduces itself
EHLO myapp.example.com
250-smtp.queensmtp.com Hello myapp.example.com
250-SIZE 26214400          // Max message size: 25MB
250-PIPELINING             // Can send multiple commands at once
250-8BITMIME               // Supports 8-bit MIME content
250-STARTTLS               // Supports TLS encryption upgrade
250-AUTH PLAIN LOGIN       // Supported auth mechanisms
250 OK

// Upgrade to TLS (if not already using port 465)
STARTTLS
220 Ready to start TLS

// Re-introduce after TLS handshake
EHLO myapp.example.com
250 OK

// Authenticate
AUTH LOGIN
334 VXNlcm5hbWU6           // Base64 "Username:"
eW91ci11c2VybmFtZQ==       // Base64 encoded username
334 UGFzc3dvcmQ6           // Base64 "Password:"
eW91ci1hcGkta2V5           // Base64 encoded password
235 Authentication successful

// Specify envelope sender
MAIL FROM:<hello@yourdomain.com>
250 OK

// Specify recipient
RCPT TO:<recipient@example.com>
250 OK

// Begin message data
DATA
354 Start mail input; end with <CRLF>.<CRLF>

// Message headers and body
From: Your Business <hello@yourdomain.com>
To: recipient@example.com
Subject: Test Email
MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8

<h1>Hello!</h1>
<p>This is a test email sent via SMTP.</p>
.
250 OK queued as abc123def456

// End session
QUIT
221 Bye

EHLO (Extended Hello) is always the first command. It identifies your client to the server and requests a list of supported extensions. The server responds with its capabilities including supported authentication methods, maximum message size, and available features like PIPELINING and STARTTLS.

STARTTLS upgrades the plain-text connection to encrypted TLS. After the TLS handshake completes, you must send EHLO again because the server capabilities may differ on the encrypted connection. This is a critical step that ensures your credentials and email content are transmitted securely.

AUTH authenticates your session. AUTH LOGIN sends the username and password as separate Base64-encoded strings. AUTH PLAIN sends both in a single Base64-encoded string. The server responds with 235 on success or 535 on authentication failure. Always authenticate after STARTTLS to ensure credentials are encrypted.

MAIL FROM specifies the envelope sender, which is the address that receives bounce notifications. This may differ from the From header visible to the recipient. The envelope sender is what receiving servers use for SPF verification.

RCPT TO specifies each recipient. You can issue multiple RCPT TO commands for multiple recipients. The server validates each address and responds with 250 for accepted or an error code for rejected addresses.

DATA signals the start of the message content. Everything after the 354 response until the terminating period on a line by itself is treated as the email message, including headers and body.

Common SMTP Sending Errors and Fixes

When SMTP sending fails, the server returns a three-digit error code with a descriptive message. Understanding these errors helps you diagnose and fix issues quickly. Here are the most common sending errors and their solutions.

Error Code Message Cause Solution
421 Too many connections You have exceeded the server's connection limit Reduce concurrent connections; use connection pooling instead of opening new connections per email
450 Requested action not taken Temporary failure, often greylisting Retry after 5-15 minutes; legitimate MTAs retry automatically
535 Authentication failed Wrong username/password or auth before STARTTLS Verify credentials; ensure STARTTLS is completed before AUTH
550 Mailbox not found Recipient address does not exist Remove address from list; do not retry (hard bounce)
552 Message size exceeds limit Email with attachments is too large Reduce attachment size or use a file-sharing link instead
554 Transaction failed Message rejected by content filter or policy Check for spam trigger words; verify authentication records; check IP reputation

Error 535 (Authentication failed) is the most common error during initial setup. The usual causes are: incorrect credentials (check for copy-paste errors including trailing whitespace), attempting authentication before STARTTLS on port 587, using account login credentials instead of SMTP-specific credentials, or the SMTP username and password being swapped. In QUEENSMTP, your SMTP username and API key are found in the Dashboard under Settings, then SMTP Credentials.

Error 550 responses vary significantly in their detailed messages. "550 5.1.1 User unknown" means the specific mailbox does not exist. "550 5.7.1 Message rejected" typically means your message was blocked by a spam filter or your sending IP is blacklisted. "550 5.7.23 SPF validation failed" means your SPF record does not authorize the sending IP. Always read the full error message, not just the numeric code, to understand the specific cause.

Sending Multipart (HTML + Text) Emails

Best practice for email sending is to include both an HTML version and a plain text version of your email in a single message. This is called a multipart/alternative message. The email client chooses which version to display based on its capabilities and the recipient's preferences. Clients that support HTML rendering will display the HTML version, while text-only clients or recipients who prefer plain text will see the text version.

Including a plain text alternative also improves deliverability. Spam filters view multipart messages more favorably than HTML-only messages because legitimate senders typically include both versions. A message with only HTML and no text alternative is a minor spam signal because it suggests the sender prioritized formatting over accessibility.

// Raw multipart/alternative email structure
From: Your Business <hello@yourdomain.com>
To: recipient@example.com
Subject: Your Order Has Shipped
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="boundary-string-123"

--boundary-string-123
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Your order #12345 has shipped!

Tracking number: 1Z999AA10123456784
Estimated delivery: March 18, 2026

View tracking: https://yourdomain.com/track/12345

--boundary-string-123
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div style=3D"font-family: Arial, sans-serif; max-width: 600px;">
  <h1 style=3D"color: #333;">Your Order Has Shipped!</h1>
  <p>Order #12345 is on its way.</p>
  <table style=3D"width: 100%; border-collapse: collapse;">
    <tr>
      <td style=3D"padding: 8px; border-bottom: 1px solid #eee;">Tracking</td>
      <td style=3D"padding: 8px; border-bottom: 1px solid #eee;">1Z999AA10123456784</td>
    </tr>
    <tr>
      <td style=3D"padding: 8px;">Est. Delivery</td>
      <td style=3D"padding: 8px;">March 18, 2026</td>
    </tr>
  </table>
  <a href=3D"https://yourdomain.com/track/12345"
     style=3D"display: inline-block; padding: 12px 24px; margin-top: 16px;
            background: #007bff; color: #fff; text-decoration: none;">
    Track Package
  </a>
</div>

--boundary-string-123--

In practice, you rarely need to construct multipart MIME messages manually. SMTP libraries handle the formatting automatically. In Nodemailer, provide both text and html properties. In Python, attach both MIMEText(text, 'plain') and MIMEText(html, 'html') to a MIMEMultipart('alternative'). In PHPMailer, set $mail->Body for HTML and $mail->AltBody for plain text. The library constructs the proper MIME structure with boundaries and content type headers automatically.

Sending Emails with Attachments via SMTP

SMTP supports file attachments through MIME encoding. Attachments are Base64-encoded and included in the message body as separate MIME parts. The overall message structure uses multipart/mixed as the top-level content type, which contains the email body (potentially itself a multipart/alternative with HTML and text) and one or more attachment parts.

When sending attachments via SMTP, keep the following in mind. Most receiving servers reject messages larger than 25MB total, including Base64 encoding overhead which increases the file size by approximately 33%. This means a 20MB attachment results in roughly a 27MB message, which will be rejected by many servers. For large files, it is better to upload the file to cloud storage and include a download link in the email.

// Node.js - Sending email with attachment via Nodemailer
const nodemailer = require('nodemailer');
const fs = require('fs');

const transporter = nodemailer.createTransport({
    host: 'smtp.queensmtp.com',
    port: 587,
    secure: false,
    auth: { user: 'your-smtp-username', pass: 'your-smtp-api-key' }
});

await transporter.sendMail({
    from: '"Your Business" <hello@yourdomain.com>',
    to: 'recipient@example.com',
    subject: 'Invoice #12345',
    html: '<p>Please find your invoice attached.</p>',
    text: 'Please find your invoice attached.',
    attachments: [
        {
            filename: 'invoice-12345.pdf',
            path: '/path/to/invoice-12345.pdf',   // File path
            contentType: 'application/pdf'
        },
        {
            filename: 'logo.png',
            path: '/path/to/logo.png',
            cid: 'logo@company'  // Content-ID for inline embedding
            // Reference in HTML: <img src="cid:logo@company">
        },
        {
            filename: 'data.csv',
            content: 'Name,Email\nJohn,john@example.com',  // String content
            contentType: 'text/csv'
        }
    ]
});

Inline attachments use the Content-ID (CID) header to embed images directly in the HTML body rather than as downloadable attachments. This is useful for including your company logo or product images that are part of the email design. Reference inline attachments in your HTML with src="cid:content-id-value". Inline images increase the message size but ensure the images display even when the recipient's email client blocks external image loading.

Email Headers Explained

Email headers carry metadata about the message that controls how it is delivered, displayed, and processed. Understanding headers helps you debug delivery issues, improve deliverability, and comply with email regulations. Here are the most important headers and their purposes.

Header Purpose Example
From Displayed sender address; used for DKIM alignment Your Business <hello@yourdomain.com>
To Displayed recipient address recipient@example.com
Reply-To Address that receives replies (can differ from From) support@yourdomain.com
Subject Email subject line Your Order Has Shipped
Message-ID Unique identifier for the message <abc123@smtp.queensmtp.com>
MIME-Version Indicates MIME formatting (always 1.0) 1.0
Content-Type Format of the message body multipart/alternative; boundary="..."
List-Unsubscribe One-click unsubscribe URL (required for bulk email) <https://yourdomain.com/unsubscribe?id=123>
X-Mailer Identifies the sending software QUEENSMTP/2.0
Received Trace header added by each server in the delivery chain from smtp.queensmtp.com (IP) by mx.google.com

The List-Unsubscribe header deserves special attention. Gmail, Yahoo, and other major providers now require this header for bulk email senders. It enables the "Unsubscribe" link that appears at the top of marketing emails in Gmail and other clients. Including this header reduces spam complaints because recipients can unsubscribe easily rather than clicking "Report Spam." The header should contain a URL that processes the unsubscribe request without requiring the recipient to log in or confirm. RFC 8058 defines the List-Unsubscribe-Post header for one-click unsubscribe, which Gmail requires for senders delivering more than 5,000 messages per day.

The Received headers form a chain that traces the email's path from sender to recipient. Each mail server that handles the message adds a Received header with its identity, the sender's IP, a timestamp, and the protocol used. These headers are read from bottom to top (the last Received header is the first server that handled the message). When debugging delivery issues, Received headers reveal where delays occurred, which servers processed the message, and whether any relay rejected or modified the message.

Online SMTP Testing Tools

Before deploying your SMTP configuration to production, test it thoroughly using the following tools and techniques to verify connectivity, authentication, and message delivery.

QUEENSMTP Dashboard Test: The built-in email test tool in your QUEENSMTP dashboard sends a test email through your configured SMTP settings and reports the result immediately. This is the fastest way to verify that your account is active, your domain is authenticated, and emails are being accepted for delivery.

Swaks (Swiss Army Knife for SMTP): Swaks is a command-line SMTP testing tool that lets you send test emails with full control over every aspect of the SMTP session. It is invaluable for debugging authentication issues, testing TLS, and verifying specific SMTP commands.

# Install swaks
# Debian/Ubuntu: apt-get install swaks
# macOS: brew install swaks

# Send a test email through QUEENSMTP
swaks \
  --to recipient@example.com \
  --from hello@yourdomain.com \
  --server smtp.queensmtp.com \
  --port 587 \
  --tls \
  --auth LOGIN \
  --auth-user your-smtp-username \
  --auth-password your-smtp-api-key \
  --header "Subject: SMTP Test" \
  --body "This is a test email sent via swaks through QUEENSMTP."

# Test with HTML content
swaks \
  --to recipient@example.com \
  --from hello@yourdomain.com \
  --server smtp.queensmtp.com \
  --port 587 \
  --tls \
  --auth LOGIN \
  --auth-user your-smtp-username \
  --auth-password your-smtp-api-key \
  --header "Subject: HTML Test" \
  --header "Content-Type: text/html" \
  --body "<h1>Test</h1><p>HTML email via swaks.</p>"

Mail-tester.com: Send a test email to the unique address provided by mail-tester.com to receive a detailed spam score report. The tool checks your SPF, DKIM, and DMARC records, analyzes your message content for spam signals, verifies your sending IP reputation, and provides an overall score from 0 to 10. Aim for a score of 9 or above. For a comprehensive walkthrough of improving your score, read our email deliverability guide. This tool is excellent for verifying that your QUEENSMTP configuration is optimized for deliverability.

MXToolbox: Use MXToolbox to check your domain's DNS records (SPF, DKIM, DMARC, MX), test your sending IP against over 100 blacklists, and perform SMTP diagnostic tests. This is the standard tool for verifying email authentication configuration and checking IP reputation.

SMTP Email Sender Frequently Asked Questions

An SMTP email sender is any tool, application, or service that sends emails using the SMTP (Simple Mail Transfer Protocol) protocol. This can range from a simple command-line tool like swaks or curl, to email client applications like Thunderbird, to web-based sending dashboards, to programmatic sending via APIs and SMTP libraries in programming languages. At the application level, an SMTP email sender connects to an SMTP server using credentials (host, port, username, password), composes a message with headers (From, To, Subject) and body content, and transmits it using SMTP commands (HELO, MAIL FROM, RCPT TO, DATA). QUEENSMTP.COM provides both a web-based dashboard sender for manual emails and SMTP/API endpoints for automated programmatic sending.

Sending emails via SMTP in your application involves configuring an SMTP client library with your provider credentials. In Node.js, use Nodemailer: create a transporter with host, port 587, auth credentials, then call transporter.sendMail() with to, from, subject, and html/text body. In Python, use smtplib: create an SMTP connection, starttls(), login with credentials, and sendmail(). In PHP, use PHPMailer or the built-in mail() function with SMTP configuration. In Ruby, use ActionMailer with SMTP settings. All languages follow the same pattern: configure connection (host, port, TLS, credentials), compose message (headers and body), and send. QUEENSMTP.COM works with standard SMTP credentials so any language or framework that supports SMTP can send through our service with zero proprietary dependencies.

SMTP sending uses the traditional email protocol where your application establishes an SMTP connection, authenticates, and transmits the email using SMTP commands over a persistent TCP connection. API sending uses HTTP REST calls where your application makes a POST request with JSON payload containing the email details. SMTP is universally supported by every email library and mail server, works with existing infrastructure, and requires no proprietary SDK. API sending is typically faster for batch operations, provides immediate synchronous response with message ID, and supports advanced features like templates and scheduling more easily. QUEENSMTP.COM supports both methods — use SMTP when working with existing mail infrastructure or simple integrations, and use the REST API when building new applications that benefit from modern HTTP-based workflows with JSON responses.

Yes, you can send bulk emails using SMTP, but you need to do it properly to maintain deliverability. For SMTP-based bulk sending: maintain a persistent SMTP connection and reuse it for multiple messages rather than connecting and disconnecting for each email, implement rate limiting to avoid overwhelming the SMTP server (QUEENSMTP.COM handles server-side rate limiting automatically), use separate connections for transactional and marketing emails, include proper headers (List-Unsubscribe, precedence: bulk), and process bounces and complaints promptly. For high-volume bulk sending (over 10,000 emails per batch), the QUEENSMTP.COM REST API batch endpoint is more efficient — it accepts up to 1,000 recipients per API call and handles the SMTP sending internally with optimal connection pooling and delivery pacing.

For quick manual email sending, several online SMTP tools are available. QUEENSMTP.COM dashboard includes a built-in email sender that lets you compose and send emails directly from the web interface with full SMTP authentication. For developers testing SMTP configurations, tools like SMTPer.net and smtp-tester.com allow you to send test emails through your SMTP credentials via a web form. For command-line testing, swaks (Swiss Army Knife for SMTP) is the gold standard. However, for production email sending, always use proper SMTP integration in your application code or QUEENSMTP.COM REST API rather than web-based sender tools. Web sender tools are best for testing and debugging, while production sending should be automated through your application with proper error handling, logging, and retry logic.

To send HTML emails via SMTP, you need to set the Content-Type header to text/html and include your HTML markup in the message body. Best practice is to send multipart emails with both HTML and plain text versions using MIME (Content-Type: multipart/alternative). In Nodemailer, set the html property on the message object alongside the text property for the plain text fallback. In Python smtplib, create a MIMEMultipart message with MIMEText parts for both text/plain and text/html. Keep your HTML email simple — use table-based layouts for compatibility, inline CSS (many email clients strip style tags), avoid JavaScript (blocked by all email clients), optimize images with alt text, and keep total email size under 100KB for best deliverability. QUEENSMTP.COM also supports dynamic HTML templates with variable substitution through the API, so you can create reusable templates and personalize them per recipient.

Tracking email metrics requires integration with your SMTP provider analytics. QUEENSMTP.COM automatically tracks delivery status (delivered, bounced, deferred) for all emails sent through SMTP or API. Open tracking works by inserting an invisible 1x1 tracking pixel in HTML emails — this is automatically handled by QUEENSMTP.COM when you enable open tracking in your account settings. Click tracking works by rewriting URLs in your email to pass through a tracking redirect — also automatically handled when click tracking is enabled. Bounce tracking processes DSN (Delivery Status Notification) responses and updates your analytics dashboard in real-time. You can access all metrics through the QUEENSMTP.COM dashboard or via webhooks that POST event data to your application endpoint for delivery, bounce, open, click, unsubscribe, and spam complaint events.

Common SMTP sending errors include: 550 5.1.1 Recipient not found — the email address does not exist, remove it from your list. 550 5.7.1 Message rejected — your content or IP is flagged as spam, check content for spam triggers and verify authentication. 421 Too many connections — you are making too many simultaneous connections, implement connection pooling and rate limiting. 454 TLS required — the server requires encryption, ensure you are using STARTTLS on port 587 or SSL on port 465. 535 Authentication failed — wrong username or password, verify your QUEENSMTP.COM credentials. 552 Message size exceeded — your email is too large, reduce attachment sizes or host files externally with links. 451 Temporary failure — try again later, implement exponential backoff retry logic. For persistent delivery issues, check your SPF/DKIM/DMARC records, verify your domain is not blacklisted using MXToolbox, and contact QUEENSMTP.COM support for deliverability analysis.

Standard SMTP protocol does not support scheduled sending natively. However, QUEENSMTP.COM REST API supports the schedule parameter to queue emails for future delivery at a specific date and time. For SMTP-based workflows, implement scheduling in your application layer using a task queue (like cron jobs, Bull, or Celery) that triggers SMTP sends at the desired time.

Attachments are sent via MIME encoding in the email body. Most SMTP libraries handle this automatically — in Nodemailer use the attachments array, in Python use MIMEBase, in PHP use PHPMailer addAttachment method. QUEENSMTP.COM supports attachments up to 25MB per message. For larger files, host them externally and include download links in the email body.

The fastest method is using QUEENSMTP.COM built-in dashboard sender — compose and send directly from the web interface with no code required. For command-line testing, use swaks: swaks --to test@example.com --from you@yourdomain.com --server smtp.queensmtp.com --port 587 --tls --auth-user YOUR_USERNAME --auth-password YOUR_PASSWORD.

While technically possible, embedding SMTP credentials directly in a mobile app is a security risk as they can be extracted through reverse engineering. Instead, create a backend API endpoint that your mobile app calls, and have the backend send emails through QUEENSMTP.COM SMTP or REST API. This keeps your credentials secure on the server side.

For SMTP-based personalization, your application generates individual emails with personalized content (name, order details, recommendations) for each recipient. QUEENSMTP.COM REST API also supports template variables — define a template with placeholders like {{name}} and pass variable values per recipient in a single API call for efficient batch personalization.

SMTP authentication (SMTP AUTH) requires a username and password before the server accepts email for relay. It prevents unauthorized users from sending email through your SMTP server. QUEENSMTP.COM requires authentication on all connections using PLAIN or LOGIN methods over TLS-encrypted connections. Without authentication, servers become open relays exploited by spammers.

Yes, QUEENSMTP.COM allows sending from any From address on a domain you have verified in your account. You can verify multiple domains and send from any address on those domains. This is useful for businesses sending from different departments (support@, sales@, billing@) or brands using a single QUEENSMTP.COM account.

You can send SMTP emails using cURL with the --url, --mail-from, --mail-rcpt, and --upload-file flags. However, for most use cases the QUEENSMTP.COM REST API with cURL is simpler: curl -X POST https://api.queensmtp.com/v1/send with your API key and JSON email data. See our developer documentation for complete examples.

Start Sending Emails with QUEENSMTP Today

Whether you send from code, a dashboard, or the command line, QUEENSMTP provides the SMTP infrastructure for reliable delivery. Dedicated IPs, full authentication, real-time tracking, and 24/7 support on every plan starting at $9 per month.