Reformat e-mail via SMTP service

Abstract: Resolve email formatting issues by constructing valid HTML with inline CSS before transmission, as SMTP only transports data and cannot alter message structure.

Created: 2026-09-03 by

SMTP is a transport protocol that moves messages; it does not reformat content. To change an email's structure or appearance, you must modify the message body before sending it via your client or code. This guide explains how to craft professional, readable HTML emails and send them through SMTP services correctly.

Understanding the Role of SMTP

The Simple Mail Transfer Protocol (SMTP) acts as a postal service for digital mail. Its sole responsibility is delivering the data payload from your application to the recipient's mail server. It has no capability to alter the visual layout, font sizes, or structural hierarchy of the text inside the message. Attempting to use SMTP settings to "reformat" an email is technically impossible because the protocol operates at a lower layer than the content itself.

Instead of relying on the transport mechanism, you must prepare the email content in the desired format within your application logic or email client. This preparation happens locally or on your server before the send() method is invoked. By constructing a well-formed message object with proper headers and body content, you ensure that the receiving client renders the email exactly as intended.

Why Formatting Matters Before Transmission

Email clients interpret different formats differently. Plain text emails are universally supported but lack styling options. HTML emails allow for complex layouts, images, and CSS styling, which enhances professionalism and readability. However, if you send malformed HTML, the email may appear broken or trigger spam filters. Therefore, the "reformatting" process is actually about constructing valid, clean markup prior to transmission.

Constructing Professional HTML Emails

To achieve a professional look, you should write semantic HTML5 that is compatible with various email clients. Many email providers strip out external stylesheets and advanced CSS features. The safest approach is to use inline CSS for all styling properties. This ensures that fonts, colors, and spacing remain consistent regardless of the recipient's email software.

  • Use Tables for Layout: While modern web design uses Flexbox or Grid, email clients still rely heavily on HTML tables for reliable alignment. Create a single-cell table for the main content area to maintain structure.
  • Inline All Styles: Convert all <style> blocks into style="..." attributes on individual tags. Tools like Premailer can automate this conversion.
  • Keep Widths Fixed: Use fixed widths (e.g., 600px) for containers to prevent the email from stretching too wide on large screens.

Sending Formatted Emails via Code

If you are automating email sends, you will likely use a library such as Python's smtplib or Node.js's Nodemailer. These libraries allow you to define the MIME type of your message body as text/html. This tells the recipient's email client to render the content as a webpage rather than plain text.

Here is a basic example using Python to send an HTML-formatted email. Note that the HTML string is constructed fully before being passed to the SMTP session.

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

def send_html_email():
    sender = "[email protected]"
    receiver = "[email protected]"
    
    # Create the message container
    msg = MIMEMultipart('alternative')
    msg['Subject'] = "Professional Email Update"
    msg['From'] = sender
    msg['To'] = receiver
    
    # Define the HTML content
    html_part = """\
    <html>
      <body style="font-family: Arial, sans-serif;">
        <h1 style="color: #333;">Hello World</h1>
        <p>This email was formatted before sending.</p>
      </body>
    </html>
    """
    
    # Attach the HTML part
    html_mime = MIMEText(html_part, 'html')
    msg.attach(html_mime)
    
    # Connect to SMTP server and send
    server = smtplib.SMTP('smtp.example.com', 587)
    server.starttls()
    server.login(sender, "password")
    server.send_message(msg)
    server.quit()

send_html_email()

In this script, the variable html_part contains the fully structured email. The MIMEText class is initialized with the second argument set to 'html', which signals the email client to parse the content as HTML. The SMTP connection handles only the delivery of this pre-formatted blob.

Ensuring Readability and Deliverability

A beautifully formatted email will fail if it lands in the spam folder. To enhance deliverability, ensure your HTML is clean and free of excessive links or suspicious keywords. Always include a plain-text fallback version of your email. This helps email clients that cannot render HTML and improves accessibility for screen readers.

You can attach both parts to your MIMEMultipart object by adding a MIMEText instance with type 'plain' first, followed by the 'html' instance. Most modern clients will display the HTML version while keeping the plain text version available as a backup.

Using Email Clients for Manual Formatting

If you are not coding but using a desktop client like Thunderbird or Outlook, formatting is handled through the composition window. Switch the view mode from "Plain Text" to "HTML" or "Rich Text." You can then use the toolbar to apply bolding, headings, and lists. These changes are embedded into the message headers automatically when you click send.

For more control, some clients allow you to edit the raw HTML source directly. This is useful for applying specific CSS tweaks that the GUI does not support. However, be cautious when editing raw code, as syntax errors can break the entire message layout.

Common Pitfalls in Email Design

Even with correct SMTP configuration, designers often make mistakes that ruin the email's appearance. Avoid using relative URLs for images; always use absolute URLs hosted on a stable server. If an image fails to load, the layout may collapse. Additionally, do not rely on JavaScript for any functionality within the email body. Email clients strictly disable scripts for security reasons, so any interactive elements will simply disappear.

Testing is crucial. Send test emails to different providers like Gmail, Yahoo, and Outlook. Each provider renders HTML slightly differently due to their proprietary engines. What looks perfect in Chrome may look broken in Apple Mail. Use testing tools to preview your email across multiple platforms before sending bulk communications.

Frequently Asked Questions

Can I change the font size after the email is sent?

No, once an email is transmitted via SMTP, its content is immutable. You cannot retroactively change the formatting of a delivered message. Any adjustments must be made in the draft stage before the send action is executed.

Why does my HTML email look broken in Gmail?

Gmail strips out many CSS rules and external stylesheets for security. If you used <link> tags for stylesheets, they will be ignored. Ensure all CSS is inlined directly within the HTML tags using the style attribute.

Is it better to use plain text or HTML for professional emails?

HTML is generally preferred for marketing and newsletters as it allows for branding and clear visual hierarchy. Plain text is safer for simple notifications but lacks aesthetic appeal. A multipart email containing both versions is the best practice for maximum compatibility.

How do I add images to my HTML email?

Host your images on a public web server and reference them with absolute URLs in the <img src="..."/> tag. Do not embed images as base64 strings unless necessary, as some clients block them. Always provide alt text for accessibility.

Does SMTP affect the speed of email rendering?

SMTP determines how quickly the email reaches the server, not how fast it renders on the recipient's device. Rendering speed depends on the recipient's hardware and email client performance. Large HTML payloads may take longer to download, so keep your code lightweight.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More