Use PHP to send MIME mail (1)

Source: Internet
Author: User
Author: KarticKrishnamurthy translator: is limodou tired of sending monotonous text notifications and emails to your friends and customers? I have considered sending attachments or embedding HTML in Mail. The answer is MIME. The following pages explain the basics of MIME and create MIME-compliant SyntaxHighli. 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.