Miva, Miva Script, Miva Empresa, Miva Mia amd Miva Merchant are registered trademarks of the Miva Corporation
 
Ivo Truxa - truXoft control systems: advanced programming and custom IT solutions home / about / webdesign / Miva / automation / contact

http://mivo.truxoft.com
MIVO!
miva beyond limits

 

MIVA®  RESOURCES:  Sending HTML e-mail with MvSMTP

by Ivo Truxa, 04/17/2001

  1. Simple HTML formated e-mail
  2. HTML e-mail with attachments
  3. Useful links
  4. User Comments

Me personally, similarly as many others who use Internet intensively, I dislike HTML formatted e-mail and in most cases find it quite annoying. However, many people ask how to send HTML formatted messages by MvSMTP. Here you go:


top


Simple HTML formated e-mail

You can send HTML formatted messages with MvSMTP in the following way. Please note the missing blank line just after the MvSMTP command. The following two lines are merged to the SMTP header and will not be visible in the message. After these two lines, there must be a blank line (without any space or tab on it!). The message in usual HTML format follows.

<MIVA STANDARDOUTPUTLEVEL="">
<MvASSIGN NAME="l.cr" VALUE="{asciichar(13) $ asciichar(10)}">
<MvSMTP TO="somebody@somewhere.com" SUBJECT="Hello"... > 
<MvEVAL EXPR="{'MIME-Version: 1.0' $ l.cr}">
<MvEVAL EXPR="{'Content-Type: text/html; charset="iso-8859-1"' $ l.cr}">
<MvEVAL EXPR="{'Content-Transfer-Encoding: 8bit' $ l.cr $ l.cr}">
<MvEVAL EXPR="{'
<HTML><head</head><body>
<H1>This is an HTML e-mail example</H1>
</body></HTML>
'}">
</MvSMTP>

You could use <MIVA STANDARDOUTPUTLEVEL="text"> as many coders do with MvSMTP, but be aware that it is definitely incorrect to use <MIVA STANDARDOUTPUTLEVEL="text"> when you are adding lines to the SMTP header. According to RFC-2821 the line-breaks in the SMTP header must be CR/LF pairs. You'll have the CR/LF pairs only if you save it in PC format and transfer the script in binary mode. Some MTA (i.e. mail servers) will refuse mail with improperly formatted SMTP header or will strip the lines out. Much safer is using STANDARDOUTPUTLEVEL="" and MvEVAL to print out the text and the CR/LF pairs.


top


HTML e-mail with attachments

If you use any images or other external elements, they have to be linked to resources available on the Web, but note that the recipient would be able to view them only as long as he is online. If you wish that the pictures are available also offline, you would need to send them as attachments in a multipart message. Please have a look at MimeConv 2.0 and its implementation mimeconv.mv for details on sending multipart messages and the RFC-2557 for the explanation of different ways of URI formatting in HTML e-mail. I'll try to add some examples or a working HTML e-mail function here later.


top

Some Useful Links

RFC-2557: MIME E-mail Encapsulation of Aggregate Documents
File Attachments with MvSMTP
MimeConv 2.0

 

top

   

Miva and some other terms used on this page are registerd trademarks of the Miva Corporation
copyright  truXoft  © 1997-2010