MIVA® RESOURCES: File Attachments with MvSMTP
Ivo Truxa
- Binary atachments
- ASCII attachments
- Useful links
- User Comments
Q: Can I attach a file using SMTP?
Yes, you can:
Binary atachments
For most binary attachments you will need to use an external program like for example the MimeConv 2.0. It may be used also for decoding attachments from incoming e-mail (MvPOP).
ASCII attachments
If you need to send just text data or such binary data that may be handled with Miva, you can achieve it directly in Miva without any external tool:
<MIVA STANDARDOUTPUTLEVEL="">
<MvASSIGN NAME="l.cr" VALUE="{asciichar(13) $ asciichar(10)}">
<MvSMTP TO="{g.to}" SUBJECT="x" MAILHOST="{g.host}" FROM="{g.from}">
<MvEVAL EXPR="{'MIME-Version: 1.0' $ l.cr}">
<MvEVAL EXPR="{'Content-Type: application/octet-stream; name="test.dat"' $ l.cr}">
<MvEVAL EXPR="{'Content-Transfer-Encoding: 8bit' $ l.cr}">
<MvEVAL EXPR="{'Content-Disposition: attachment; filename="test.dat"' $ l.cr $ l.cr}">
<MvEVAL EXPR="{'
Here comes your text or data. It may contain any characters,
inclusive non-printable ones - you can use for example the
asciichar() function here to send them.
'}">
</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
Some Useful Links
MimeConv 2.0
RFC-2045: MIME - Format of Internet Message Bodies
RFC-2046: MIME - Media Types
RFC-2047: MIME - Message Header Extensions for Non-ASCII Text
RFC-2048: MIME - Registration Procedures
RFC-2049: MIME - Conformance Criteria and Examples
RFC-821: SMTP - Simple Mail Transfer Protocol
RFC-1652: SMTP Service Extension for 8bit-MIMEtransport
RFC Editor
Search the RFC Database
top
|