Download the PHP package popphp/pop-mime without Composer

On this page you can find all versions of the php package popphp/pop-mime. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pop-mime

pop-mime

Build Status Coverage Status

Join the chat at https://popphp.slack.com Join the chat at https://discord.gg/TZjgT74U7E

Overview

pop-mime is a component that provides the ability to work with MIME messages and content. With it, you can generate properly-formatted MIME messages with all their related headers and parts, or you can parse pre-existing MIME messages into their respective objects and work with them from there. This can be utilized with mail and HTTP components, such as pop-mail and pop-http.

pop-mime is a component of the Pop PHP Framework.

Install

Install pop-mime using Composer.

composer require popphp/pop-mime

Or, require it in your composer.json file

"require": {
    "popphp/pop-mime" : "^2.0.0"
}

Top

Quickstart

Creating a Simple MIME Message:

This will produce the following MIME message:

Top

Parts

The main message object is essentially a top-level part object. A part object can contain headers, a body object or other nested part objects. When a part object has nested parts, this creates a multipart message. The required boundaries are automatically generated.

The example above would produce:

Top

Attachments

Part objects can be file attachments as well.

The example above would produce:

Top

Headers

The header and header value objects allow for easy creation and granular control over the header values of a MIME message.

Top

Header Values

Header values can be passed into a header object as strings, but they will become header value objects. When fetching them, you can get the value object like this:

The benefit of the header value object is that it allows fine-grain control over the header value, including scheme, parameters, the delimiter and whether or not to force quotes.

Example 1:
Example 2:

You can always get the header value as a string:

Top

Multiple Header Values

In some cases, a header may need to contain multiple values. They can be passed as an array to the constructor:

or, by individual header value object:

You can access each header value by index:

Top

Multipart Messages

There is a interface to assist in easily creating multipart messages, instead of doing it the more manual way outlined in the above examples.

HTTP Multipart Form

If you just need the main form parts without the top-level header and MIME preamble, you can do that like this:

And that will render just the form data content, removing the top-level header and the preamble:

HTTP Multipart Form with a File

You can also create form data with files in a couple of different ways as well:

Example 1:

Example 2:

In example 1, the file on disk is passed and put into the form data from there. In example 2, the file contents are explicitly passed to the contents key to set the file data into the form data. Also, for flexibility, the following case-insensitive keys are acceptable for Content-Type:

Top

Parsing

Note:

This component adheres to the MIME standard which uses CRLF ("\r\n") for line breaks. If a mime message does not adhere to this standard, parsing may not work as intended.

Parsing a message:

To parse MIME messages and content, you can take the string of MIME message content and pass it in the following method and it will return a message object with all of the related headers and parts.

Parsing a header string:

If you happen to have the MIME header string, you can parse just that like below. This will return an array of header objects:

Parsing a body string:

If you happen to have the MIME body string, you can parse just that like below. This will return an array of part objects:

Parsing a single part string:

And if you happen to have the string of a single MIME part, you can parse just that like below. This will return a part object:

Parsing form data:

As a special case, if you have multipart/form-data MIME content, you can parse it like below. This will return a form data array:

It's important to note that in order for the above example to work properly, it has to have a header with at least the Content-Type defined, including the boundary that will be used in parsing the form data:

Top


All versions of pop-mime with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package popphp/pop-mime contains the following files

Loading the files please wait ....