Thanks to visit codestin.com
Credit goes to github.com

Skip to content

horde/Mime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,182 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Horde\Mime

MIME message handling library for PHP 8.2+.

Provides immutable value objects for building, parsing and rendering RFC 2822/2045 MIME messages.

Installation

composer require horde/mime

Quick Start

use Horde\Mime\MessageBuilder;
use Horde\Mime\MessageRenderer;
use Horde\Mime\MimeParser;
use Horde\Mime\PartBuilder;

// Compose a message
$builder = new MessageBuilder();
$builder->setFrom('[email protected]')
    ->setTo('[email protected]')
    ->setSubject('Hello')
    ->setBody('Plain text body', flowed: true)
    ->addAttachment('/path/to/file.pdf');

$composed = $builder->build();
$raw = MessageRenderer::render($composed->part, $composed->headers);

// Parse a message
$part = MimeParser::parse($rawMessage);
echo $part->fullType();        // e.g. "multipart/mixed"
echo $part->children[0]->body; // first child's decoded body

// Build parts directly
$part = PartBuilder::text('Hello world')->build();
$html = PartBuilder::html('<p>Hello</p>')->build();
$attachment = PartBuilder::attachment($data, 'report.pdf', 'application/pdf')->build();

Documentation

License

LGPL 2.1 - see LICENSE for details.

About

Horde MIME Library

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages