1. Go to this page and download the library: Download popphp/pop-mime library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
popphp / pop-mime example snippets
use Pop\Mime\Message;
use Pop\Mime\Part\Body;
$message = new Message();
$message->addHeaders([
'Subject' => 'Hello World',
'To' => '[email protected]',
'Date' => date('m/d/Y g:i A')
]);
$body = new Body('Hello World!');
$message->setBody($body);
echo $message;
use Pop\Mime\Message;
use Pop\Mime\Part;
$message = new Message();
$message->addHeaders([
'Subject' => 'Hello World',
'To' => '[email protected]',
'Date' => date('m/d/Y g:i A')
]);
$message->setSubType('alternative');
$html = new Part();
$html->addHeader('Content-Type', 'text/html');
$html->setBody('<html><body><h1>This is the HTML message.</h1></body></html>');
$text = new Part();
$text->addHeader('Content-Type', 'text/plain');
$text->setBody('This is the text message.');
$message->addParts([$html, $text]);
echo $message;
use Pop\Mime\Message;
use Pop\Mime\Part;
$message = new Message();
$message->addHeaders([
'Subject' => 'Hello World',
'To' => '[email protected]',
'Date' => date('m/d/Y g:i A'),
'MIME-Version' => '1.0'
]);
$message->setSubType('mixed');
$html = new Part();
$html->addHeader('Content-Type', 'text/html');
$html->setBody('<html><body><h1>This is the HTML message.</h1></body></html>');
$text = new Part();
$text->addHeader('Content-Type', 'text/plain');
$text->setBody('This is the text message.');
$file = new Part();
$file->addHeader('Content-Type', 'application/pdf');
$file->addFile('test.pdf');
$message->addParts([$html, $text, $file]);
echo $message;
$header = new Header('Content-Type', 'text/html');
echo $header;
$header = new Header('Content-Type', 'text/html');
print_r($header->getValue()); // Returns an instance of Pop\Mime\Header\Value
use Pop\Mime\Part\Header;
$header = new Header('Content-Disposition');
$value = new Header\Value('attachment');
$value->addParameter('filename', 'filename.jpg');
$header->addValue($value);
echo $header;