Lucas Leonardo wrote:
> I have tried to write a program that can send a simple mail directly to
> a destination SMTP server just using the SMTP command and work ok.
> Now I'm trying to expand that program to have the capability to send a
> mail that has attachment, my problem is how to tell the SMTP server
> that my data is MIME.
It isn't the SMTP server which needs to know that the message is
MIME-encapsulated; it's the user's MUA.
> If I put the attachment data that has been encoded
> using Base64, it just being the part of the message body.
Yep.
To send a single binary file in base64, you need to specify headers
such as:
> MIME-Version: 1.0
> Content-Type: application/octet-stream
> Content-Transfer-Encoding: base64
To send a multi-part message (e.g. text with attachments), you need to
specify headers such as:
> MIME-Version: 1.0
> Content-Type: multipart/mixed; boundary="9sJMqIAiT7aKi"
> Content-Transfer-Encoding: 7bit
where the boundary string can be just about anything.
Then, each part of the message needs to be preceded by `--', followed
by the boundary string ("9sJMqIAiT7aKi" in this example), followed by
some headers, then a blank line, then the content.
The message needs to be terminated with `--', followed by the boundary
string, followed by `--'. For example:
> --9sJMqIAiT7aKi
> Content-Type: text/plain; charset=us-ascii
> Content-Description: message body text
> Content-Transfer-Encoding: 7bit
>
> This is some text
>
> --9sJMqIAiT7aKi
> Content-Type: application/octet-stream
> Content-Description: an attachment
> Content-Disposition: attachment; filename="foo.gz"
> Content-Transfer-Encoding: base64
>
> 9sJMqIAiT7aKiVRSED0GUqBIABSqqr16A3sAE+O+T6r6efa9Lfb3bvXe3aX1nuxopBCkn0VP
> td12tld93tjzG67oUNR4Pqj6fQGPe577z3H0+2sXiu+3VpUA1Vvvd14p8Zumb7voLsebN307
> AOAHsTo6TaKdXYbNetYaJ27E5YA8IJ2/FPmn03B8R/+LuSKcKEgEsI/bgA==
>
> --9sJMqIAiT7aKi--
For more examples, try playing with the metasend program (from the
metamail package), and looking at what it generates. You might wish to
use some of the code from metamail instead of rewriting it yourself.
> Should I use ESMTP? I have tried to search the document for ESMTP in
> internet but can not find it.
The transport protocol (SMTP, ESMTP, UUCP, etc) isn't relevant.
--
Glynn Clements <[EMAIL PROTECTED]>