Skip to content
doubtly

1 answer

Best answer

Answer: Gmail's compose window has no HTML-code mode. To send an HTML email, either format the message in Gmail itself, paste rendered HTML into the compose box, or send it through Gmail's SMTP server from a program.

  1. Use Gmail's formatting toolbar. Gmail already sends messages as HTML. Bold, colours, lists, links and images that you add with the toolbar become HTML in the sent mail.
  2. Paste rendered HTML. Open your HTML file in a web browser, select the page (Ctrl + A), copy it (Ctrl + C) and paste it into the Gmail compose box. Gmail keeps most of the formatting. Do not paste the raw code, or the tags will appear as plain text.
  3. Send from code using Gmail's SMTP server. Set the content type of the message to text/html. Gmail requires 2-step verification and an App Password for this. Example in Python:
import smtplib
from email.mime.text import MIMEText

html_body = "<h2>Hello</h2><p>This is an <b>HTML</b> email.</p>"
msg = MIMEText(html_body, "html")      # mark the body as HTML
msg["Subject"] = "HTML test"
msg["From"] = "you@gmail.com"
msg["To"] = "friend@example.com"

with smtplib.SMTP("smtp.gmail.com", 587) as server:
    server.starttls()
    server.login("you@gmail.com", "your-app-password")
    server.send_message(msg)

Email clients support only simple HTML, so use inline CSS (style="…") and table-based layouts for best results.

Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.