Sending HTML mail via sendmail cli

Here’s how to do it

# ( cat <<HEADERS; cat /root/file.html) | sendmail -oi -t
From: sender@domain.tld
To: recipients@domain.tld
Subject: we send HTML instead of plain text
Mime-Version: 1.0
Content-type: text/html
Content-transfer-encoding: 8bit

HEADERS <- type CTRL+D then press ENTER

We should set Mime-Version , Content-Transfer-Encoding and Content-Type headers properly. The issue of correct MIME transfer encoding is one of the many possible complexities which is simply ignored here.


ie.

From - Wed Sep 16 10:37:50 2009
X-Account-Key: account2
X-UIDL: UID86652-1215485813
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
X-Mozilla-Keys:
Return-Path: <root@domain.tld>
X-Original-To: hari.h@domain.tld
Delivered-To: hari.h@domain.tld
Received: by mx1.domain.tld (Postfix, from userid 0)
	id 74482300093; Wed, 16 Sep 2009 10:37:14 +0700 (WIT)
From: hari.h@domain.tld
To: hari.h@domain.tld
Subject: we send HTML instead of plain text
Mime-Version: 1.0
Content-type: text/html
Content-transfer-encoding: 8bit
Message-Id: <20090916033714.74482300093@mx1.domain.tld>
Date: Wed, 16 Sep 2009 10:37:14 +0700 (WIT)

<html>
<head>
<title>test</title>
</head>
<body>
test
</body>
</html>

simple huh? 😆

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *