1. Go to this page and download the library: Download vaibhavpandeyvpz/phemail 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/ */
vaibhavpandeyvpz / phemail example snippets
$parser = new Phemail\MessageParser();
$message = $parser->parse(__DIR__ . '/sample.eml');
echo $message->getHeaderValue('subject');
# outputs 'Testing simple email'
echo $message->getHeaderValue('date');
# outputs 'Sat, 22 Nov 2008 15:04:59 +1100'
echo $message->getHeaderValue('content-type');
# outputs 'text/plain'
echo $message->getHeaderAttribute('content-type', 'charset');
# outputs 'US-ASCII'
echo $message->getContents();
/**
* @desc To extract emails from headers, you could use any RFC 822
* internet address parser e.g., pear/mail.
*/
$addresses = (new Mail_RFC822())->parseAddressList($message->getHeaderValue('to'));
foreach ($addresses as $address) {
echo 'Name: ', $address->personal, '<br>', 'Email: ', $address->mailbox, '@', $address->host;
}
eml
Mime-Version: 1.0
Message-Id: <[email protected]>
From: Vaibhav Pandey <[email protected]>
To: Vaibhav Pandey <[email protected]>
Subject: Testing simple email
Date: Sat, 22 Nov 2008 15:04:59 +1100
Content-Type: text/plain; charset=US-ASCII; format=flowed
Content-Transfer-Encoding: 7bit
This is simple as f*** plain text email message.
Regards,
Vaibhav Pandey
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.