Author: Kartic Krishnamurthy Translator: limodou
Are you tired of sending monotonous text notifications and emails to your friends and customers? I have considered sending attachments or sending emails
Embedded in HTML.
The answer is MIME. The following pages explain the basic knowledge of MIME, create MIME-compliant information, and end with a working php (as the mainstream development language) class, this class allows you to send MIME-compliant emails. Note that references to call scripts, callers, and so on indicate that scripts of the classes to be developed are used, and client programs/MUA indicate that the client programs or emails to be read use the agent programs.
MIME Basics
MIME indicates the multi-purpose Internet Mail Extension protocol. MIME extends the basic text-Oriented Internet mail system so that
The message contains binary attachments.
MIME utilizes the fact that RFC 822 imposes a limit on the content of the message body: the only restriction is that it can only be used simply.
ASCII text. Therefore, MIME information is composed of normal Internet Text emails, which have special information that complies with RFC 822.
Header and formatted Information body (the attachment is represented by a subset of ASCII ). These MIME headers provide a special way to indicate attachments in the mail.
.
MIME Information Analysis
The information of a common text mail contains a header (To: From: Subject: and so on) and a body (Hello Mr .,
And so on ). It is not surprising that a MIME-compliant message contains an information header. Each part of the message is called a MIME segment, and each segment is prefixed.
With a special header. MIME mail is only an extension based on RFC 822 mail. However, it has its own RFC specification set.
Header field
Based on the position in the package, the MIME header is generally divided into the MIME information header and the MIME field header. The MIME header indicates the entire email.
And only the header of each MIME segment .)
MIME information headers include:
MIME-Version:
This header provides the MIME Version Number used. This value is 1.0.
Content-Type:
It defines the data type so that the data can be processed properly. Valid types: text, image, audio, video,
Applications, multipart, and message. Note that any binary attachment should be called application/octet-
Stream. Some examples of this header are: image/jpg, application/mswork, multipart/mixed, which is only a few
Part.
Content-Transfer-Encoding:
This is the most important of all headers, because it describes the encoding method for the data, and the customer/MUA will use it to parse the attachment.
. For each attachment, you can use one of 7bit, 8bit, binary, quoted-printable, base64, and custom encoding.
Code. 7-bit encoding is a common encoding method used in the us ascii character set, that is, to keep it as it is. 8bit and
Binary encoding is generally not required. Protects standard human-readable text if it is transmitted through a gateway that has an impact on the format,
Quoted printable can be used. Base64 is a common method. It provides
A brain-free choice; it is usually used in binary, non-text data. Note that any non-7bit data must use a Mode
Code, so that it can pass the Internet Mail Gateway!
Content-ID:
This header is useful if the Content-Type is message/external-body or multipart/alternative. It is beyond the scope of this article.
Content-Description:
This is an optional Header. It is a free text description of any information segment. The description must use the us-ascii code.
Content-Disposition:
A pilot header that provides a prompt to the customer Program/MUA to determine whether to display the attachment within the row or as a separate attachment.
MIME field header (the header that appears in the actual MIME attachment part), except the MIME-Version header, can have any of the above header fields. If a MIME header is part of an information block, it acts on the entire information body. For example, if Content-Transfer-Encoding is displayed in the message header, it is applied to the entire information body, but if it is displayed in a MIME segment, it can only be used in that segment.