Git Product home page Git Product logo

php-mime-mail-parser's Introduction

php-mime-mail-parser

A fully tested email parser for PHP 8.0+ (mailparse extension wrapper).

It's the most effective PHP email parser around in terms of performance, foreign character encoding, attachment handling, and ease of use. Internet Message Format RFC 822, 2822, 5322.

Latest Version Total Downloads Software License

Why?

This extension can be used to...

  • Parse and read email from Postfix
  • Read messages (Filename extension: .eml)
  • Create webmail
  • Store email information such a subject, HTML body, attachments, etc. into a database

Is it reliable?

Yes. All known issues have been reproduced, fixed and tested.

We use GitHub Actions, Codecov, Codacy to help ensure code quality. You can see real-time statistics below:

CI Coverage Code Quality

How do I install it?

The easiest way is via Composer.

To install the latest version of PHP MIME Mail Parser, run the command below:

composer require php-mime-mail-parser/php-mime-mail-parser

Requirements

The following versions of PHP are supported:

  • PHP 8.0
  • PHP 8.1
  • PHP 8.2
  • PHP 8.3

Previous Versions:

PHP Compatibility Version
HHVM php-mime-mail-parser 2.11.1
PHP 5.4 php-mime-mail-parser 2.11.1
PHP 5.5 php-mime-mail-parser 2.11.1
PHP 5.6 php-mime-mail-parser 3.0.4
PHP 7.0 php-mime-mail-parser 3.0.4
PHP 7.1 php-mime-mail-parser 5.0.5
PHP 7.2 php-mime-mail-parser 7.1.2
PHP 7.3 php-mime-mail-parser 7.1.2
PHP 7.4 php-mime-mail-parser 7.1.2

Make sure you have the mailparse extension (http://php.net/manual/en/book.mailparse.php) properly installed. The command line php -m | grep mailparse needs to return "mailparse".

Install mailparse extension

Debian, Ubuntu & derivatives

sudo apt install php-cli php-mailparse

MacOS

brew install php
pecl install mailparse

Other platforms

sudo apt install php-cli php-pear php-dev php-mbstring
pecl install mailparse

From source

AAAAMMDD should be php-config --extension-dir

git clone https://github.com/php/pecl-mail-mailparse.git
cd pecl-mail-mailparse
phpize
./configure
sed -i 's/#if\s!HAVE_MBSTRING/#ifndef MBFL_MBFILTER_H/' ./mailparse.c
make
sudo mv modules/mailparse.so /usr/lib/php/AAAAMMDD/
echo "extension=mailparse.so" | sudo tee /etc/php/7.1/mods-available/mailparse.ini
sudo phpenmod mailparse

Windows

You need to download mailparse DLL from http://pecl.php.net/package/mailparse and add the line extension=php_mailparse.dll to php.ini accordingly.

How do I use it?

Loading an email

You can load an email in 4 differents ways:

require_once __DIR__.'/vendor/autoload.php';

$path = 'path/to/email.eml';
$parser = new PhpMimeMailParser\Parser();

// 1. Either specify a file path (string)
$parser->setPath($path); 

// 2. or specify the raw mime mail text (string)
$parser->setText(file_get_contents($path));

// 3. or specify a php file resource (stream)
$parser->setStream(fopen($path, "r"));

// 4. or specify a stream to work with a mail server (stream)
$parser->setStream(fopen("php://stdin", "r"));

Get the metadata of the message

Get the sender and the receiver:

$rawHeaderTo = $parser->getHeader('to');
// return "test" <[email protected]>, "test2" <[email protected]>

$arrayHeaderTo = $parser->getAddresses('to');
// return [["display"=>"test", "address"=>"[email protected]", false]]

$rawHeaderFrom = $parser->getHeader('from');
// return "test" <[email protected]>

$arrayHeaderFrom = $parser->getAddresses('from');
// return [["display"=>"test", "address"=>"[email protected]", "is_group"=>false]]

Get the subject:

$subject = $parser->getHeader('subject');

Get other headers:

$stringHeaders = $parser->getHeadersRaw();
// return all headers as a string, no charset conversion

$arrayHeaders = $parser->getHeaders();
// return all headers as an array, with charset conversion

Get the body of the message

$text = $parser->getMessageBody('text');
// return the text version

$html = $parser->getMessageBody('html');
// return the html version

$htmlEmbedded = $parser->getMessageBody('htmlEmbedded');
// return the html version with the embedded contents like images

Get attachments

Save all attachments in a directory

$parser->saveAttachments('/path/to/save/attachments/');
// return all attachments saved in the directory (include inline attachments)

$parser->saveAttachments('/path/to/save/attachments/', false);
// return all attachments saved in the directory (exclude inline attachments)

// Save all attachments with the strategy ATTACHMENT_DUPLICATE_SUFFIX (default)
$parser->saveAttachments('/path/to/save/attachments/', false, Parser::ATTACHMENT_DUPLICATE_SUFFIX);
// return all attachments saved in the directory: logo.jpg, logo_1.jpg, ..., logo_100.jpg, YY34UFHBJ.jpg

// Save all attachments with the strategy ATTACHMENT_RANDOM_FILENAME
$parser->saveAttachments('/path/to/save/attachments/', false, Parser::ATTACHMENT_RANDOM_FILENAME);
// return all attachments saved in the directory: YY34UFHBJ.jpg and F98DBZ9FZF.jpg

// Save all attachments with the strategy ATTACHMENT_DUPLICATE_THROW
$parser->saveAttachments('/path/to/save/attachments/', false, Parser::ATTACHMENT_DUPLICATE_THROW);
// return an exception when there is attachments duplicate.

Get all attachments

$attachments = $parser->getAttachments();
// return an array of all attachments (include inline attachments)

$attachments = $parser->getAttachments(false);
// return an array of all attachments (exclude inline attachments)

Loop through all attachments

foreach ($attachments as $attachment) {
    echo 'Filename : '.$attachment->getFilename().'<br>';
    // return logo.jpg
    
    echo 'Filesize : '.filesize($attach_dir.$attachment->getFilename()).'<br>';
    // return 1000
    
    echo 'Filetype : '.$attachment->getContentType().'<br>';
    // return image/jpeg
    
    echo 'MIME part string : '.$attachment->getMimePartStr().'<br>';
    // return the whole MIME part of the attachment
    
    $stream = $attachment->getStream();
    // get the stream of the attachment file

    $attachment->save('/path/to/save/myattachment/', Parser::ATTACHMENT_DUPLICATE_SUFFIX);
    // return the path and the filename saved (same strategy available than saveAttachments)
}

Postfix configuration to manage email from a mail server

To forward mails from Postfix to the PHP script above, add this line at the end of your /etc/postfix/master.cf (to specify myhook to send all emails to the script test.php):

myhook unix - n n - - pipe
  				flags=F user=www-data argv=php -c /etc/php5/apache2/php.ini -f /var/www/test.php ${sender} ${size} ${recipient}

Edit this line (register myhook)

smtp      inet  n       -       -       -       -       smtpd
        			-o content_filter=myhook:dummy

The PHP script must use the fourth method (see above) to work with this configuration.

And finally the easiest way is to use my SaaS https://mailcare.io

Can I contribute?

Feel free to contribute!

git clone https://github.com/php-mime-mail-parser/php-mime-mail-parser
cd php-mime-mail-parser
composer install
./vendor/bin/phpunit

If you report an issue, please provide the raw email that triggered it. This helps us reproduce the issue and fix it more quickly.

License

The php-mime-mail-parser/php-mime-mail-parser is open-sourced software licensed under the MIT license

php-mime-mail-parser's People

Contributors

antoineaugusti avatar anton-bel avatar bits4breakfast avatar designosis avatar digilive avatar dorianfm avatar duncan3dc avatar eryno avatar exorus avatar fijiwebdesign avatar fkoyer avatar gharlan avatar gmta avatar hadyhallak avatar ianchadwick avatar iateadonut avatar lucasvdh avatar luiz-brandao avatar m42e avatar martyix avatar mbabker avatar myselfhimself avatar ocramius avatar odknt avatar poison avatar thibauddauce avatar thomaslandauer avatar uda avatar vincentdauce avatar xqus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-mime-mail-parser's Issues

Parsing DSN-s

It is possible parse DSN parts into an associative array?

Reporting-MTA: dns; szepe.net
Arrival-Date: Mon, 03 Aug 2015 13:05:19 +0200
Received-From-MTA: dns; localhost (localhost [127.0.0.1])

Final-Recipient: rfc822; [email protected]
Action: failed
Status: 5.0.0
Remote-MTA: dns; mail.maxer.hu [178.238.210.100]
Diagnostic-Code: smtp; 550 This is not incoming server!

It looks like a message header. Except the empty line in the middle.

failure to parse email (html/text)

the below email is parsed with empty text/html parts
works fine on many other emails

From bounce-450_HTML-114564821-312680-7000715-13067@bounce.email.gap.com  Sun Aug 11 15:40:44 2013
Return-Path: <bounce-450_HTML-114564821-312680-7000715-13067@bounce.email.gap.com>
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: from mta12.email.gap.com (mta12.email.gap.com [199.122.123.134])
by snappomatic.com (Postfix) with ESMTP id 077B7422CB
for <[email protected]>; Sun, 11 Aug 2013 15:40:44 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; s=200608; d=email.gap.com;
h=From:To:Subject:Date:List-Unsubscribe:MIME-Version:Reply-To:Message-ID:Content-Type; [email protected];
bh=VMq9JSoWk5u8OYtRv03+c2KqkZs=;
b=W/MiZRV78OAc4awpNTM2YBhpfFBTGe6jSecgV1qxqEjwnwmqMaXc5NSSti9E9mECN7lEsNnPsaG6
Gs60DLEmNRa+1qnrbQCPQqBvCTkrPfsZ/H2b1NJ2LrBQuMFspK5cv1BD0Lcn0uKnAIZS/SBgFJtj
B2XmiXrZ4zEp9Lqxgfg=
DomainKey-Signature: a=rsa-sha1; c=nofws; q=dns; s=200608; d=email.gap.com;
b=arEixI7qro7UBeu/x3wxd2DsUaSiEZPvb10jdsEIyk3X0wQdSi9Zku7sT5FhYSBdCL2pL2/MHzno
STbUh7+A7EBmSXfDj/Rgc33R2F0WBzXeMzL7IgXw9kN4ROsEC7Mh65jtQfhxBkijnXzf/fUZFvEl
CJdRTtUCy7QJTYfMCWk=;
Received: by mta12.email.gap.com id h0uo8e163hso for <[email protected]>; Sun, 11 Aug 2013 09:40:54 -0600 (envelope-from <bounce-450_HTML-114564821-312680-7000715-13067@bounce.email.gap.com>)
From: "Gap" <[email protected]>
To: <[email protected]>
Subject: Final hours to shop the GAP FRIENDS EVENT!
Date: Sun, 11 Aug 2013 09:40:51 -0600
List-Unsubscribe: <mailto:leave-fd521075750b5c392848-fe2f1571716102797d1671-fecb177177620c7d-fe9b13707564037c70-fefe1573756203@leave.email.gap.com>
MIME-Version: 1.0
Reply-To: "Gap" <reply-fecb177177620c7d-450_HTML-114564821-7000715-13067@email.gap.com>
x-job: 7000715_312680
Message-ID: <[email protected]>
Content-Type: multipart/alternative;
boundary="jzixueVetTTE=_?:"

This is a multi-part message in MIME format.

--jzixueVetTTE=_?:
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: 8bit

GAP
http://click.email.gap.com/?qs=4d634f679d740ecf17880aaaf6bce8eee4b92233c6371e9b0b9a01c8c7206059673778a8a087a401

----------------------------------------------------------------------

Click below to view this message from Gap in a web browser:
http://click.email.gap.com/?qs=4d634f679d740ecfdcdcec517ed5343ae85eea00969e59d68e67d9a437d1b972b6243795f362d468

----------------------------------------------------------------------

Privacy Policy:
http://click.email.gap.com/?qs=4d634f679d740ecfa0a502f2252a48323cba4443ee3cf9cc12564dde49bac6be566bf2cc68696516

Unsubscribe:
http://click.email.gap.com/?qs=4d634f679d740ecffe6bdd56eaf4bfdc6511aa5a467230e8d38f7dbe38319b580946c8192c05334e

Customer Services, 100 Gap Online Drive, Grove City, OH 43123-8605.

--jzixueVetTTE=_?:
Content-Type: text/html;
charset="utf-8"
Content-Transfer-Encoding: 8bit



<html>
<head>
<title>Final hours to shop the GAP FRIENDS EVENT!</title>
<style type="text/css">
.ReadMsgBody{width:100%;}
.ExternalClass{width:100%;}
.ExternalClass{line-height:100%;}
table td {border-collapse: collapse;}
</style>
</head>
<body style="-webkit-text-size-adjust: none; margin: 0px; padding: 0px; -ms-text-size-adjust:none;">
<img src="http://click.email.gap.com/open.aspx?ffcb10-fecb177177620c7d-fe3915717764017e741578-fe9b13707564037c70-ff66107575-fe2f1571716102797d1671-fefe1573756203" width="1" height="1">

<table width="828" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><!-- 20130514_GPUS_Header -->
<!-- Begin Preheader + Nav Bar -->
<table border="0" cellpadding="0" cellspacing="0" width="828" align="center">
<tr>
<td align="left" style="font-family:Arial,Helvetica,sans-serif; font-size:12px; line-height:15px; color:#666666; padding-top:15px; padding-bottom:36px;">
<a href="http://click.email.gap.com/?qs=4d634f679d740ecfdffc8ac28aafad5fe339e990a32213391c1d84995757832e123bc7882025584460e36d502b932736" target="_blank" style="color:#0033FF; text-decoration:underline;" ><span style="color:#0033FF;">The Gap FRIENDS Event ends today, 8/11. Online: 35% off. In stores: 30% off.</span></a>
<span style="font-size:10px; line-height:13px;"> Can't see images? <a href="http://click.email.gap.com/?qs=4d634f679d740ecfc182eb4077b4b814c63c9ae8ddf4e4b9d7a5922d863fc5de7a525b58444a5c85" target="_blank" style="color:#0033FF; text-decoration:underline;" ><span style="color:#0033FF;">Click here</span></a>.</span></td>
</tr>
<tr>
<td align="left" width="828" height="130">
<table border="0" cellpadding="0" cellspacing="0" width="828" align="center">
<tr>
<td width="828" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="828" align="center">
<tr>
<td width="76" height="76" valign="top" style="mso-line-height-rule:exactly;"><a href="http://click.email.gap.com/?qs=4d634f679d740ecfbc0f297602097b86a2d00fb717185d028d078232dc406bd9fb8ddbe2c5b1c9b7a858ec98635f71fe" target="_blank" ><img alt="GAP" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/10/2013_Summer-Top-Nav_US_03.jpg" width="76" height="76" border="0" style="display:block; font-family:Arial,Helvetica,sans-serif; font-size:10px; color:#000000;" /></a></td>
<td width="462" height="76" valign="top" style="mso-line-height-rule:exactly;"><img alt="" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/3/GPUS_Header_Spacer.gif" border="0" style="display:block; font-family:Arial,Helvetica,sans-serif; font-size:10px; color:#000000;" />
</td>
<td width="290" height="76" style="mso-line-height-rule:exactly;"><a href="http://click.email.gap.com/?qs=4d634f679d740ecfe159324f2c951063210fc013cf0e8d6b9490c28060c3a4d7ffed4f3f910de9150de523710998e9c2" target="_blank" ><img alt="FREE SHIPPING ON ANY ORDERS OVER $50. FREE RETURNS ON ALL ORDERS." src="http://image.email.gap.com/lib/fe9b13707564037c70/m/10/2013_Summer-Top-Nav2_03.jpg" width="290" height="76" border="0" style="display:block; font-family:Arial,Helvetica,sans-serif; font-size:10px; color:#000000;" /></a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="828" height="54" align="center">
<tr>
<td width="66" height="54" style="mso-line-height-rule:exactly;">
<a href="http://click.email.gap.com/?qs=4d634f679d740ecff21bbdeac48c29f5975da7cb6999ee87d64f404d63a0864fa89d86890953c5c8587f0fd572dd505f" target="_blank" ><img style="display:block;" alt="WOMEN" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/10/2013_Summer-Top-Nav_US_05.jpg" width="66" height="54" border="0" /></a></td>
<td width="66" height="54" style="mso-line-height-rule:exactly;">
<a href="http://click.email.gap.com/?qs=4d634f679d740ecfe534826430ac1ed9146848b633647c41a00b6e1ad47e2f35c1880c18952816e12c4a2a2575c88142" target="_blank" ><img style="display:block;" alt="BODY" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/10/2013_Summer-Top-Nav_US_06.jpg" width="66" height="54" border="0" /></a></td>
<td width="76" height="54" style="mso-line-height-rule:exactly;">
<a href="http://click.email.gap.com/?qs=4d634f679d740ecf326ff6f04faa32d7824da10c46307c090147fe5aa186246d9b2961f546a461242ca0540bbd0536f2" target="_blank" ><img style="display:block;" alt="GAPFIT" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/10/2013_Summer-Top-Nav_US_07.jpg" width="76" height="54" border="0" /></a></td>
<td width="108" height="54" style="mso-line-height-rule:exactly;">
<a href="http://click.email.gap.com/?qs=4d634f679d740ecfbf30eab653744b0af9da7514f70332e905a529a479f4bed5180c3f181dde223a9c09a2479e47b489" target="_blank" ><img style="display:block;" alt="MATERNITY" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/10/2013_Summer-Top-Nav_US_08.jpg" width="108" height="54" border="0" /></a></td>
<td width="58" height="54" style="mso-line-height-rule:exactly;">
<a href="http://click.email.gap.com/?qs=4d634f679d740ecff400352c6014657098ef4820168d771c99902019cc94f7a80cca29e02df6b8566a212aa413b0f795" target="_blank" ><img style="display:block;" alt="MEN" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/10/2013_Summer-Top-Nav_US_09.jpg" width="58" height="54" border="0" /></a></td>
<td width="68" height="54" style="mso-line-height-rule:exactly;">
<a href="http://click.email.gap.com/?qs=4d634f679d740ecfd54a87c978b27b130e14429dfc31821575d596ae50c425c792adc369781a854ee5f9e2b3abd8799e" target="_blank" ><img style="display:block;" alt="GIRLS" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/10/2013_Summer-Top-Nav_US_10.jpg" width="68" height="54" border="0" /></a></td>
<td width="65" height="54" style="mso-line-height-rule:exactly;">
<a href="http://click.email.gap.com/?qs=4d634f679d740ecfe75638097384c22da8ec1be3c0dbf479fc0e784b9d25ac3e0927d8e04abcba5637d7a488ba08768f" target="_blank" ><img style="display:block;" alt="BOYS" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/10/2013_Summer-Top-Nav_US_11.jpg" width="65" height="54" border="0" /></a></td>
<td width="133" height="54" style="mso-line-height-rule:exactly;">
<a href="http://click.email.gap.com/?qs=4d634f679d740ecf9eea869d251e5abd15d81203c10eff18feb420e638035d62a82890f43f8f88d3261dd44b5dab950e" target="_blank" ><img style="display:block;" alt="TODDLER GIRL" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/10/2013_Summer-Top-Nav_US_12.jpg" width="133" height="54" border="0" /></a></td>
<td width="129" height="54" style="mso-line-height-rule:exactly;">
<a href="http://click.email.gap.com/?qs=4d634f679d740ecf7783e92dc38019ac40ad2a881bf2de2c8c5780d196ddea39c719b509a7057c7be94ed8550ab61947" target="_blank" ><img style="display:block;" alt="TODDLER BOY" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/10/2013_Summer-Top-Nav_US_13.jpg" width="129" height="54" border="0" /></a></td>
<td width="59" height="54" style="mso-line-height-rule:exactly;">
<a href="http://click.email.gap.com/?qs=4d634f679d740ecfd47b1d027f70d094581376835f3309462d631d746f1d561877c82d4abab5c936ab0c04945239287f" target="_blank" ><img style="display:block;" alt="BABY" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/10/2013_Summer-Top-Nav_US_14.jpg" width="59" height="54" border="0" /></a></td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
</table>
<!-- End Preheader + Nav Bar -->
<!-- Begin Top Banner -->

<!-- End Top Banner --></td>
</tr>
</table>
<table width="828" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="374" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="http://click.email.gap.com/?qs=4d634f679d740ecfa716d9d3e2151f1117b2c6363f327e90924b0e0d7cfbca3087c816e7d7e5e9b24fa210e1c85436dd"  target="_blank"><img style="display:block;" alt="IN STORES & ONLINE | FINAL HOURS! | THE GAP FRIENDS EVENT | ONLINE 35% OFF YOUR PURCHASE | IN STORES 30% OFF YOUR PURCHASE | ENDS TODAY 8/11." border="0" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/12/081113_FriendsEvent_03.jpg" width="374" height="583"></a></td>
</tr>
<tr>
<td><table width="374" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="114" style="font-size:0px; mso-line-height-rule:exactly; line-height:0px;"><a href="http://click.email.gap.com/?qs=4d634f679d740ecf8844744a9aeda351cb1a0ede32e3a8fb6cd377928fadc2af5cc3630efdba4871a329875c3e03248d"  target="_blank"><img style="display:block;" alt="ENTER" border="0" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/12/0811_FF_AllDiv_LC_2.jpg" width="114" height="14"></a></td>
<td width="91" height="14" align="center" bgcolor="#ccffff" style="font-family:Arial, Helvetica, sans-serif; font-size:11px; color:#0099cc; font-weight:bold;">GAPFRIENDS</td>
<td width="170" style="font-size:0px; mso-line-height-rule:exactly; line-height:0px;"><a href="http://click.email.gap.com/?qs=4d634f679d740ecf0afdfae76b44b2a0185f6e361720bba5a5c3d3da704dd889c7e3cefbe0ac49ed9352cacb60e12e96"  target="_blank"><img style="display:block;" alt="AT CHECKOUT." border="0" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/12/0811_FF_AllDiv_LC_3.jpg" width="170" height="14"></a></td>
</tr>
</table></td>
</tr>
<tr>
<td><a href="http://click.email.gap.com/?qs=4d634f679d740ecfbdba8a771183c4fa45ad32b15cc10bd5b44a1dbfdbd4650615478bfdc960f298fd0727c722b50078"  target="_blank"><img style="display:block;" alt="DISCOUNT TAKEN AT REGISTER IN STORES." border="0" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/12/081113_FriendsEvent_06.jpg" width="374" height="48"></a></td>
</tr>
<tr>
<td><table width="374" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="http://click.email.gap.com/?qs=4d634f679d740ecf1d55b3e830dc3080cd074c1f8780544a1b00391db566df4a9dee02807011590e575be3e6c8267dad"  target="_blank"><img style="display:block;" alt="SHOP NOW" border="0" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/12/0811_FF_AllDiv_LC_5.jpg" width="174" height="27"></a></td>
<td><a href="http://click.email.gap.com/?qs=4d634f679d740ecfb229432149ec9f1fd7c60feefad44a99ea121d1468e3c7cf219a04e46bf0fd6006a0384b7a247305"  target="_blank"><img style="display:block;" alt="FIND A STORE" border="0" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/12/0811_FF_AllDiv_LC_6.jpg" width="200" height="27"></a></td>
</tr>
</table></td>
</tr>
<tr>
<td><a href="http://click.email.gap.com/?qs=4d634f679d740ecfa040f45e92652e2ced9378dd19431e35f85e07f0c7951297f16bce259b12e013b6e1ca2574068f5d"  target="_blank"><img style="display:block;" alt="NOT VALID AT GAP OUTLET. " border="0" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/12/081113_FriendsEvent_08.jpg" width="374" height="58"></a></td>
</tr>
</table></td>
<td><a href="http://click.email.gap.com/?qs=4d634f679d740ecfb1aa42fbd62b353cf6a743a5412fbf8fe0053e2abb63644f54c3837dec41ef6118a26a636c31954b"  target="_blank"><img style="display:block;" alt="Gap Friends Event" border="0" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/12/081113_ALL_FriendsEvent_3_04.jpg" width="454" height="730"></a></td>
</tr>
</table>
<!-- Begin Major Content Area --><!-- End Major Content Area -->
<table width="828" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="left"><!-- 20130514_GPUS_Footer -->
<!-- Begin Bottom Banner -->

<!-- End Bottom Banner -->
<!-- Begin Evergreen Footer -->
<!-- 20130425_GPUS_Evergreen -->

<table border="0" cellpadding="0" cellspacing="0" width="828" align="center"><tr><td align="left" style="font-size:0px; mso-line-height-rule:exactly; line-height:0px;"><!-- 20130617_GPUS_W_Evergreen -->
<table border="0" cellpadding="0" cellspacing="0" width="828" height="347" align="center"><tr>
<td width="274" height="347" style="mso-line-height-rule:exactly;">
<a href="http://click.email.gap.com/?qs=4d634f679d740ecf9c9d6482b78be8e9ef99be73950b7f16370323019458a64d8b1dcc7123813fb4"  target="_blank"><img style="display:block;" alt="1969 PREMIUM DENIM | Premium fabrics. Flattering fits. | SHOP WOMEN'S 1969 DENIM" border="0" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/10/20130617_Womens_EVERGREEN_03.jpg" width="274" height="347"></a></td>
<td width="281" height="347" style="mso-line-height-rule:exactly;">
<a href="http://click.email.gap.com/?qs=4d634f679d740ecf150369b9b83a168bc82ced404c49aab6e29378cf048976672f49a14e78183ada"  target="_blank"><img style="display:block;" alt="NEW ARRIVALS | Just in! Everything you want right now. | SHOP WOMEN'S NEW ARRIVALS" border="0" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/10/20130617_Womens_EVERGREEN_04.jpg" width="281" height="347"></a></td>
<td width="273" height="347" style="mso-line-height-rule:exactly;">
<a href="http://click.email.gap.com/?qs=4d634f679d740ecf31fbfe500fb55a02b60df7c59b0cf9bd799cdfc1896762b54c2664d5e7f358dc"  target="_blank"><img style="display:block;" alt="MEET GAPFIT | All your workouts start here. | SHOP GAPFIT" border="0" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/10/2013_ADU_EVERGREEN_US_W_05.jpg" width="273" height="347"></a></td>
</tr></table></td></tr>
</table>


<!-- End Evergreen Footer -->
<!-- Begin EDFS, Store Locator, Footer -->
<table border="0" cellpadding="0" cellspacing="0" width="828" align="center"><tr><td align="left" style="padding-top:15px; padding-bottom:15px;"><table cellpadding="0" cellspacing="0" border="0" width="828" align="center">
<tr>
<td width="828" height="55" valign="top"><a href="http://click.email.gap.com/?qs=4d634f679d740ecf07646e1a28a49b62013fcbb3cdc1639436006fe371725b6070851691e61d392b" target="_blank" ><img alt="FREE SHIPPING ON ALL ORDERS OVER $50. No code. No hassle. | FREE RETURNS ON ALL ORDERS." src="http://image.email.gap.com/lib/fe9b13707564037c70/m/11/20130716_FreeShip_BotBanner.jpg" width="828" height="55" border="0" style="display:block; font-family:Arial,Helvetica,sans-serif; font-size:10px; color:#000000;" /></a></td>
</tr>
</table></td></tr>
<tr><td align="left"><table cellpadding="0" cellspacing="0" width="828" border="0" align="center">
<tr>
<td>
<table cellpadding="0" cellspacing="0" border="0" width="828" align="center">
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="828">
<tr>
<td width="828" align="left">
<a href="http://click.email.gap.com/?qs=4d634f679d740ecff2732417353e3e1c9b776ce896177b5cec23b8bbf02ad345129acc5af95b5b34"  target="_blank"><img alt="Where's your nearest Gap Store? | FIND IT NOW" src="http://image.email.gap.com/lib/fe9b13707564037c70/m/9/052313_static_storeLocator_03.jpg" width="828" height="55" border="0" style="display:block; font-family:Arial, Helvetica, sans-serif; font-size: 10px;" /></a>
</td>
</tr>
</table>

</td>
</tr>
</table></td></tr>
<tr><td align="left" style="padding-bottom:6px;">





<table cellpadding="0" cellspacing="0" border="0" width="828" align="center">
<tr>
<td style="padding-top:36px;">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td> <a href="http://click.email.gap.com/?qs=4d634f679d740ecf6fee272a1dc130ae4ff8b953748710ea8b285eb7fd10959221207bd5bb786e7a"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/1/preferences.gif" alt="Update Your Email Preferences" width="113" height="23" style="display:block; font-family: Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>
</td>
<td> <a href="http://click.email.gap.com/?qs=4d634f679d740ecf18cc716e8814a7dd3ba82d59c41351b8b1d074bd80f282a10282dd2c840f5281"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/1/gap_style.gif" alt="Questions Feedback" width="206" height="23" style="display:block; font-family: Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>
</td>
<td> <a href="http://click.email.gap.com/?qs=4d634f679d740ecfa4d0053058053909e0dfa5e178b7f3b534ae90445e8784db4c42c34d6920b5d3"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/1/gap_card.gif" alt="GapCard" width="95" height="23" style="display:block; font-family: Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>
</td>
<td> <a href="http://click.email.gap.com/?qs=4d634f679d740ecff28c723b0536da444429538d6d71cb144cec16f71771b2bdbe4b58a9c60c2fc7"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/1/store_locator.gif" alt="Store Locator" width="120" height="23" style="display:block; font-family: Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>
</td>
<td> <a href="http://click.email.gap.com/?qs=4d634f679d740ecff207d0fc5c0cd1cdbf2f3bd7d7d0746b58e5f67f2bb04487d7713466bb11c3c1"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/1/return_policy.gif" alt="Return Policy" width="158" height="23" style="display:block; font-family: Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>
</td>
<td> <img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/1/stay_connected.gif" alt="Stay Connected" width="136" height="23" style="display:block; font-family: Arial, Helvetica, sans-serif; font-size: 10px;" border="0" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right">
<table cellpadding="0" cellspacing="0" border="0" width="89">
<tr>
<td style="padding-right:10px;"><a href="http://click.email.gap.com/?qs=4d634f679d740ecf8d071ac9651eb51ef8205cd15e152689509a6399eaf8e580540456a630979a65"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/1/fb_icon.gif" alt="Facebook" width="23" height="23" style="display:block; font-family: Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>
</td>
<td style="padding-right:10px;">
<a href="http://click.email.gap.com/?qs=4d634f679d740ecfe2beaff783b817d01dcfb507de5597f606940a25d15156acbab851e625fa9043"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/5/110812_ALL_giftCardTemplate_4.jpg" alt="Pinterest" width="23" height="23" style="display:block; font-family: Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>

</td>
<td><a href="http://click.email.gap.com/?qs=4d634f679d740ecf59442916b34b83b7e175912221e62a14e703abf2771b7c2095af1518c6d6cf26"  target="_blank"><img src="http://image.email.gapinc.com/lib/fe9813707564027577/m/5/twitterIconUpdate.jpg" alt="Twitter" width="23" height="23" style="display:block; font-family: Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right" style="padding-top:10px">
<table cellpadding="0" cellspacing="0" border="0" width="89">
<tr>
<td style="padding-right:10px;"><a href="http://click.email.gap.com/?qs=4d634f679d740ecf5cfe4afea26793db936657ecadc0f0c869cf1613aba79402aae7e9727666197b"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/5/110812_ALL_giftCardTemplate_3.jpg" alt="Instagram " width="23" height="23" style="display:block; font-family: Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>
</td>
<td style="padding-right:10px;"><a href="http://click.email.gap.com/?qs=4d634f679d740ecfef6c7dad4fe9f99f72d51c7ecd05a3e9fa9b2c3012cd0e09f4adaf7bf5331cee"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/5/110812_ALL_giftCardTemplate_2.jpg" alt="Styld.by" width="21" height="23" style="display:block; font-family: Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>
</td>
<td><a href="http://click.email.gap.com/?qs=4d634f679d740ecfd91e9d2c8b32f0781af4133d1b1b05a088bdeb6e74849cc33335a49aaba858b7"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/5/110812_ALL_giftCardTemplate_1.jpg" alt="Mobile" width="23" height="23" style="display:block; font-family: Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/1/visit_all_brands.gif" width="700" height="46" border="0" style="display:block; font-family: Arial, Helvetica, sans-serif; font-size: 10px;" />
</td>
</tr>
<tr>
<td style="padding-bottom:25px;">
<table cellpadding="0" cellspacing="0" border="0" width="541" align="center">
<tr>
<td style="padding-right:21px;"> <a href="http://click.email.gap.com/?qs=4d634f679d740ecf098ab325058c12b9f8d2556e747b65cb943984f0112a5c503f2dac48d7ac8c27"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/1/G_gap_brand_image.jpg" alt="Gap" width="25" height="27" border="0" style="display:block; font-family:Arial, Helvetica, sans-serif; font-size: 10px;" /></a>
</td>
<td style="padding-right:21px;"> <a href="http://click.email.gap.com/?qs=4d634f679d740ecf55495e8e987a2b4c840d8ab3b80eb494b90078f384b1a883eaffb6ede093c2ca"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/1/G_old_navy.jpg" alt="Old Navy" width="68" height="27" style="display:block; font-family:Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>
</td>
<td style="padding-right:21px;"> <a href="http://click.email.gap.com/?qs=4d634f679d740ecf94d49f7759254fcb0164a5571db363a45dce14cc4106b36482ad9d001f7c5636"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/1/G_banana_republic.jpg" alt="Banana Republic" width="79" height="27" style="display:block; font-family:Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>
</td>
<td style="padding-right:21px;"> <a href="http://click.email.gap.com/?qs=4d634f679d740ecf462214de3948dc2588a5561d8aa9d5fc1c014daed1f5f845faaa605c141019eb"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/1/G_piperlime.jpg" alt="Piperlime" width="77" height="27" style="display:block; font-family:Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>
</td>
<td style="padding-right:21px;">  <a href="http://click.email.gap.com/?qs=4d634f679d740ecf0edbc77c247ebbd514eba8ee47a203e7157cabd166a9af869cd25ea7d084559b"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/1/G_athleta.jpg" alt="Athleta" width="61" height="27" style="display:block; font-family:Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>
</td>
<td style="padding-right:21px;">  <a href="http://click.email.gap.com/?qs=4d634f679d740ecf5f78a5b0c99a5d7ff77fd7209d5d066ce695ba43b9498fb5676b9fdc520e2474"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/1/G_gap_outlet.jpg" alt="Gap Outlet" width="25" height="27" style="display:block; font-family:Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>
</td>
<td> <a href="http://click.email.gap.com/?qs=4d634f679d740ecfe0e816fcd67a437639ba85d3e38f8ae9c495de3bbe4b01ec7a8d7207233bc0e4"  target="_blank"><img src="http://image.email.gap.com/lib/fe9b13707564037c70/m/1/G_b_r_factory_store.jpg" alt="Banana Republic Factory Store" width="80" height="27" style="display:block; font-family:Arial, Helvetica, sans-serif; font-size: 10px;" border="0" /></a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" style="font-family: Arial, Helvetica, sans-serif; font-size: 10px; padding-bottom:20px;"> <a href="http://click.email.gap.com/?qs=4d634f679d740ecf9f38e05600c060134a78ac27e37e72e3a8d9185c78107109e9772c5ad51f1d0f"  target="_blank">PRIVACY POLICY</a> | <a href="http://click.email.gap.com/?qs=4d634f679d740ecf6b9bf19b0993b4a5f3d9ec7a286f2df968b6cf87ae773affedf2917404390528"  target="_blank">UNSUBSCRIBE</a>
</td>
</tr>
<tr>
<td> <img src="http://login.dotomi.com/ucm/UCMController?dtm_com=2&dtm_cid=2366&dtm_cmagic=d3b1fb&dtm_fid=103&dtm_format=6&cli_promo_id=99&dtm_email_hash=1280034bd9948c922340b3b225adc533&dtm_user_id=170831124&dtmc_segment_name=GPRESTET&dtmc_email_category=20130811_GPUS_FF_AllDiv_LC&dtmc_drop_id=20130811&dtmc_brand=GPUS" width="1" height="1" border="0"> <img src="http://ads.dotomi.com/cookieredir/2366/pub1.php?a1280034bd9948c922340b3b225adc533170831124=1" width="1" height="1" border="0"> <img src="http://ads.dotomi.com/cookieredir/2366/pub2.php?a1280034bd9948c922340b3b225adc533170831124=1" width="1" height="1" border="0"> <img src="http://ads.dotomi.com/cookieredir/2366/pub3.php?a1280034bd9948c922340b3b225adc533170831124=1" width="1" height="1" border="0">
<img src="http://ads.dotomi.com/cookieredir/2366/pub4.php?a1280034bd9948c922340b3b225adc533170831124=1" width="1" height="1" border="0"> <img src="http://ads.dotomi.com/cookieredir/2366/pub5.php?a1280034bd9948c922340b3b225adc533170831124=1" width="1" height="1" border="0"> <img src="http://ads.dotomi.com/cookieredir/2366/pub6.php?a1280034bd9948c922340b3b225adc533170831124=1" width="1" height="1" border="0"> <img src="http://ads.dotomi.com/cookieredir/2366/pub7.php?a1280034bd9948c922340b3b225adc533170831124=1" width="1" height="1" border="0"> <img src="http://ads.dotomi.com/cookieredir/2366/pub8.php?a1280034bd9948c922340b3b225adc533170831124=1" width="1" height="1" border="0"> <img src="http://ads.dotomi.com/cookieredir/2366/pub9.php?a1280034bd9948c922340b3b225adc533170831124=1" width="1" height="1" border="0">
<img src="http://ads.dotomi.com/cookieredir/2366/pub10.php?a1280034bd9948c922340b3b225adc533170831124=1" width="1" height="1" border="0">
</td>
</tr>
</table></td></tr>
</table>
<!-- End EDFS, Store Locator, Footer -->
<table border="0" cellpadding="0" cellspacing="0" width="828" align="center"><tr><td align="left" style="font-family:Arial,Helvetica,sans-serif; font-size:10px; line-height:13px; color:#999999;">

<!-- Begin Top Banner Legal -->

<!-- End Top Banner Legal -->
<table border="0" cellpadding="0" cellspacing="0" width="828" align="center"><tr><td align="left" style="font-family:Arial,Helvetica,sans-serif; font-size:10px; line-height:13px; color:#999999;">Offer valid August 8 - August 11, 2013 from 12:00 am ET to 11:59 pm ET online and at Gap, GapBody, GapKids and babyGap stores in the U.S. only (including Puerto Rico). Offer not valid at Gap Outlet or Gap Factory Stores. Discount applies to merchandise only. In store exclusions include LP by Linea Pelle, SeaVees, Minnetonka, ’47 Brand, Linea Pelle, Vismaya, Baggu, Jonathan Adler, Casio, Clap, Coloud, Native Union, Moleskine, Sarut, Alice Ritter Brooklyn, bkr, Diggin Active Inc., Lunchskins, International Arrivals, Threadless, Fashion Angels, Verla, Chronicle Publishing, Begin Again, Natural Products Worldwide Co., Sophie the Giraffe, Hape, Haba, Melissa & Doug, Bellaband, Hello!Lucky, Puma, Puppet Workshop, Areaware, Penguin Group, Random House Inc., Tailgate, Charm It!,
Junk Food and any other products from brands other than Gap. Online exclusions include Junk Food™, Star Wars™, Clu™, Minnetonka™, Threadless®, Tailgate®, Alice Ritter™, Beatrix Potter™, NuBra®, Medela® and Bravado®. Price adjustment allowed only once within 7 days of previous in-store purchases only. Not combinable with other offers or discounts except for Reward Cards, 10% GapCard Tuesday, 10% GapCard Shopping Pass and the initial acquisition discount when approved for a new GapCard. Not combinable with Gap Inc. Employee Discount. Discount taken at register. <br>
<br></td></tr></table>
<!-- Begin Bottom Banner Legal -->

<!-- End Bottom Banner Legal -->
<span style="font-weight:bold;">Everyday Free Shipping</span> is valid in the U.S. only (including Puerto Rico) on purchases of $50 or more in the same order. Gift cards, packaging, taxes and prior purchases do not qualify toward the minimum purchase requirement and offer cannot be applied to such items. Eligible customers must select this option during checkout in order to receive free shipping. Offer is good for the order's first "ship-to" address anywhere in the U.S. (including Puerto Rico). If you choose another shipping option, additional charges will apply. Cannot be combined with other offers or discounts. No adjustments on previous purchases. Offer is non-transferable and subject to change without notice. Not valid on international shipments.
<br /><br />
If you have any questions about our privacy policy, contact our customer service center via email at <a href="mailto:[email protected]">[email protected]</a> or call us at 1-800-GAP-STYLE (1-800-427-7895) option 4. You may also contact us by postal mail at gap.com Customer Services, 100 Gap Online Drive, Grove City, OH 43123-8605.<br />
<br />
&copy; 2013 Gap Inc.</td></tr></table></td>

</tr>
</table></td>
</tr>
</table>
</body>
</html>

--jzixueVetTTE=_?:--

last line dropped in getMessageBody('text')

If the last line of the parsed raw file doesn't end with a /n, getMessageBody('text') leaves it out.

Here's the sample.txt file ... make sure it doesn't end in CR or LF:

From [email protected] Wed May 21 00:19:23 2014
Received: from asd.sender.com ([212.25.25.25]:18356)
    by asd.asdasd.com with esmtp (Exim 4.82)
    (envelope-from <[email protected]>)
    id 1WmsNV-0001yF-87
    for [email protected]; Wed, 21 May 2014 00:19:23 +0200
Received: from ([127.0.0.1]) with MailEnable ESMTP; Tue, 20 May 2014 21:19:21 +0200
From: "sender" <[email protected]>
Subject: sender email test
 status: 5
To: [email protected]
Content-Type: text/plain
Content-Transfer-Encoding: 8bit
Date: Tue, 20 May 2014 21:19:21 +0200



************************************************************
* Here's the text body...
************************************************************

You will not see the next line!

Here's the last line of the text ... Houdini!

Tested with ...

require_once('parser.class.php');
$e = new MimeMailParser(); // i'm using your latest version, just renamed things a bit
$e->setPath( './sample.txt' );
$text = $e->getMessageBody('text');
echo $text;

Does not decode headers according to RFC2047

What steps will reproduce the problem?

  • Parse a message with a header (i.e. subject line) encoded according to
    RFC2047

What is the expected output? What do you see instead?

  • Expected output is the decoded subject line
  • Instead, the subject line is passed through unencoded, i.e.
    =?UTF-8?Q?stuff_A=C3=A5_B=E2=88=AB_C=C3=A7_D=E2=88=82_E?=
    =?UTF-8?Q?=C2=B4_R=C2=AE_$=C2=A2?=

What version of the product are you using? On what operating system?

  • Revision 15

Please provide any additional information below.

  • Attached is a diff of my changes to properly decode the message headers
    if they are encoded. The code is mostly copied from Pear's Mail_Mime class.
  • This also fixes the issue where the message body is not decoded properly
    based on its encoding type

Source : https://code.google.com/p/php-mime-mail-parser/issues/detail?id=8

PHP Mail Parse + PHP 7

Hi

Just to know if any plan are made for support by the version 7 of php

Many thanks !

No filename should not stop parser

When an attachment has no filename or the filename is not found, the parser stops. It should not stop but choose a random or static filename.
At least, the behaviour should be an configurable option

if (isset($part['disposition-filename'])){
    …
} else if (isset($part['content-name'])) {
    …
} else {
    $part['disposition-filename']="noname";
    // other option : $part['disposition-filename']=md5(uniqid());
}

Install not easy contrary to advertised

requires 3 package managers, composer, pecl and apt. Kind of a rant but I'm flabbergasted by this emerging trend. "Composer will install dependencies! Oops it doesn't really there are other requirements, PECL will! Oops, just kidding."

Why not simply use the lowest common denominator that is apt?

Anyways, would love to use but installing 2 and using 3 package managers to parse emails is beyond my will and I'm opposed to it in principle.

It should also be noted that all 3 package managers are independent from one another, if php5-imap changes, the other 2 will be none the wiser. So the great problem of dependencies that package managers solve is out the window with such an approach.

Sorry for the rant.

Comparison between forks.

Hi, I have been taking a look at other forks of this library and found one with a recent fix that yours doesn't seem to have. Please take a look:

message/php-mime-mail-parser@a4fe1d8

Would you care commenting on this issue? I'm about to pick a library to start working with. How does your fork compare to this other one?

Thanks.

hhvm : 3 failures

Build failed https://travis-ci.org/eXorus/php-mime-mail-parser/jobs/38973864

  1. eXorus\PhpMimeMailParser\ParserTest::testFromPath with data set #16 ('m0018', '[Korea] Name', '[email protected]', '"[email protected]" [email protected]', array('COUNT', 1, 'My traveling companions!'), array('MATCH', ''), array(array('=?ks_c_5601-1987?B?u+fB+C5KUEc=?=', 174, '', 0, 'image/jpeg', 'attachment', '567f29989506f21cea8ac992d81ce4c1'), array('ATT00001.txt', 25, 'iPhone', 1, 'text/plain', 'attachment', '095f96b9d5a25d051ad425356745334f')), 0)

Failed asserting that false is true.

/home/travis/build/eXorus/php-mime-mail-parser/test/ParserTest.php:464

  1. eXorus\PhpMimeMailParser\ParserTest::testFromText with data set #16 ('m0018', '[Korea] Name', '[email protected]', '"[email protected]" [email protected]', array('COUNT', 1, 'My traveling companions!'), array('MATCH', ''), array(array('=?ks_c_5601-1987?B?u+fB+C5KUEc=?=', 174, '', 0, 'image/jpeg', 'attachment', '567f29989506f21cea8ac992d81ce4c1'), array('ATT00001.txt', 25, 'iPhone', 1, 'text/plain', 'attachment', '095f96b9d5a25d051ad425356745334f')), 0)

Failed asserting that false is true.

/home/travis/build/eXorus/php-mime-mail-parser/test/ParserTest.php:579

  1. eXorus\PhpMimeMailParser\ParserTest::testFromStream with data set #16 ('m0018', '[Korea] Name', '[email protected]', '"[email protected]" [email protected]', array('COUNT', 1, 'My traveling companions!'), array('MATCH', ''), array(array('=?ks_c_5601-1987?B?u+fB+C5KUEc=?=', 174, '', 0, 'image/jpeg', 'attachment', '567f29989506f21cea8ac992d81ce4c1'), array('ATT00001.txt', 25, 'iPhone', 1, 'text/plain', 'attachment', '095f96b9d5a25d051ad425356745334f')), 0)

Failed asserting that false is true.

wrong parsing "subject" (my working code)

function convert_chars($char_code,$text_to_decode) {
if ($char_code == 'default' || $char_code == '' || $char_code == 'X-UNKNOWN'){
$text_to_decode=$text_to_decode;
} elseif (strtolower($char_code) == 'UTF-8') {
$text_to_decode=$text_to_decode;
} else {
$text_to_decode=iconv($char_code, "UTF-8//TRANSLIT", $text_to_decode);
} return $text_to_decode; }

$subject =$Parser->parts[1][headers][subject];
$decode = imap_mime_header_decode($subject);
$subject="";
foreach ($decode as $subject_part) {
$subject_part_decode=convert_chars($subject_part->charset,$subject_part->text);
$subject=$subject.$subject_part_decode;
}

BCC parsing failure

Hi,
first of all thanks a lot for the great plugin. It works for most emails, but recently I noticed issue with parsing when email send using BCC field. In this case TO: email header contains: undisclosed recipient; which causing error. Header example with BCC:
From: Test <[email protected]> Reply-To: Test <[email protected]> To: Undisclosed Recipients <[email protected]> Message-ID: <[email protected]>
I was able to find recipient email addresses in Received from part (for <[email protected]>), but this part of the headers apparently ignored.

Return-Path: <[email protected]>Received: from nm41-vm6.bullet.mail.gq1.yahoo.com (nm41-vm6.bullet.mail.gq1.yahoo.com. [67.195.87.93]) by mx.google.com with ESMTPS id cg8si9129786pac.134.2015.05.23.13.24.04 for <[email protected]> (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 23 May 2015 13:24:05 -0700 (PDT) Received-SPF: pass (google.com: domain of [email protected] designates 67.195.87.93 as permitted sender) client-ip=67.195.87.93;

Thank you

Warning when parsing a message with multiple From headers

php-mime-mail-parser is great for parsing messages coming from different sources, including ones that are not correctly formatted. There's one case though that is not being handled correctly - messages having multiple From headers. Usually it's just the same From header repeated twice. I know it's technically incorrect, but we receive messages like this from time to time and need to find some way to parse them.

A PHP warning is generated by the iconv_mime_decode() function, which in our case means that processing of the message stops:

WARNING: iconv_mime_decode() expects parameter 1 to be string, array given in /www/php-mime-mail-parser/src/eXorus/PhpMimeMailParser/Parser.php on line 375

#1 /www/php-mime-mail-parser/src/eXorus/PhpMimeMailParser/Parser.php(375): iconv_mime_decode(Array, 2, 'UTF-8')
#2 /www/php-mime-mail-parser/src/eXorus/PhpMimeMailParser/Parser.php(166): eXorus\PhpMimeMailParser\Parser->decodeHeader(Array)
#3 /www/get-mail.php(54): eXorus\PhpMimeMailParser\Parser->getHeader('from')

Meeting request not recognised

schermafbeelding 2015-05-08 om 17 03 13

When I receive an invitation from an exchange server, this sometimes is embedded in the text as content-type "text/calendar" and this is not recognized as an attachment.

How can I handle these?

Mailparse drops too many malformed emails

Hey there,
I've been testing php-mime-mail-parser on a database of several million emails, and found that close to 2% of them fail to be translated correctly by php-mime-mail-parse. The fault is probably with Mailparse. Here's an example, an email sent via Microsoft Windows Live (2009) from Sweden:

Delivered-To: [email protected]
Received: by 10.152.1.193 with SMTP id 1csp311490lao;
        Mon, 20 Oct 2014 05:33:31 -0700 (PDT)
Return-Path: <[email protected]>
Received: from vps4596.inmotionhosting.com (vps4596.inmotionhosting.com. [74.124.217.238])
        by mx.google.com with ESMTPS id fb7si7786786pab.30.2014.10.20.05.33.30
        for <[email protected]>
        (version=TLSv1 cipher=RC4-SHA bits=128/128);
        Mon, 20 Oct 2014 05:33:30 -0700 (PDT)
Message-ID: <14FBD481E1074C79A706F0C071746F3D@acerDator>
From: =?utf-8?Q?sende=C3=A4r?= <[email protected]>
To: "test" <[email protected]>
References: <[email protected]>
Subject: Re: Maya Ethnobotanicals - Emails
Date: Mon, 20 Oct 2014 14:33:24 +0200
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="----=_NextPart_000_0018_01CFEC72.CE424470"
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Mailer: Microsoft Windows Live Mail 14.0.8117.416
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8117.416
X-Source: 
X-Source-Args: 
X-Source-Dir: 

Det här är ett flerdelat meddelande i MIME-format.

------=_NextPart_000_0018_01CFEC72.CE424470
Content-Type: text/plain;
    charset="utf-8"
Content-Transfer-Encoding: quoted-printable

This email will not be captured correctly by php-mime-mail-parser.

Mailparse is unable to handle poorly formed emails. For example ...

    Det h=E4r =E4r ett flerdelat meddelande i MIME-format.

... is directly above this quoted-printable wrapper, thanks to the =
Swedish email client Microsoft Windows Live (circa 2009), adding UTF-8 =
chars where there should only be ascii. At least, that's what I think =
the problem is.

------=_NextPart_000_0018_01CFEC72.CE424470--

The line just below the headers, Det här är ett flerdelat meddelande i MIME-format (Swedish for This is a multi-part message in MIME format), is clearly the problem, since the email body will only contain "Det h".

I'm not sure if there's a solution, but losing one in 50 emails is too much, I think. We keep running into Mailparse limitations. Is there a better parser out there?

Support for PHP 5.3

I'm using CentOS 6 based server with stock php 5.3. Seems to work fine, and better than the original google code project from which this was forked.

Is there a specific reason 5.4 and up only are mentioned?

unable to retrieve attachments if content-disposition is not provided

What steps will reproduce the problem?

try to save the attachment of a mail without the content-disposition mime header

What is the expected output? What do you see instead?
to save the attachment, instead no attachments seems to be present.

What version of the product are you using? On what operating system?
i'm using the latest version on Linux with PHP 5.2.11

Please provide any additional information below.

For me worked the attached workaround on function getAttachments()

Source : https://code.google.com/p/php-mime-mail-parser/issues/detail?id=19

php-mime-mail-parser truncating attachments

Whilst using php-mime-mail-parser to parse some emails and extract attachments. In two cases I've found php-mime-mail-parser truncating attachments. I've tested with Zend php email libs and it can extract the attachments correctly.

Unfortunately I can't attach the raw email here for privacy reasons. Should you want to look into this what is best way to share a raw email with you privately?

My email is [email protected].

undefined constant DS

Parser.php does:

require_once __DIR__ . DS . 'Attachment.php';

This is a fatal error because there is no DS constant.

There is no reason not to use forward-slashes as directory separators; PHP automatically converts them to the system-specific directory separators.

require_once __DIR__ .'/Attachment.php';

Adds a function for retrieving the inline attachments

/**

  • Returns the attachments contents in order of appearance
  • @return Array
  • @param $type Object[optional]
    */
    public function getEmbeddedAttachments() {
    $attachments = array();
    foreach($this->parts as $part) {
    $partHeaders = $this->getPartHeaders($part);
    if(array_key_exists('content-id', $partHeaders))
    {
    $attachments[] = new MimeMailParser_attachment(
    $partHeaders['content-id'],
    $this->getPartContentType($part),
    $this->getAttachmentStream($part),
    '',
    $this->getPartHeaders($part)
    );
    }
    }
    return $attachments;
    }

Pull encoded messagetext

Is it also possible to get the raw text from a message, so not decoded? I'd like to store this in my database.

Problem with Debian

Hi,
I have a problem during the installation of mailparse pecl extension on a Debian system.

When I try to install I get this error:

pecl install mailparse-2.1.6
downloading mailparse-2.1.6.tgz ...
Starting to download mailparse-2.1.6.tgz (36,538 bytes)
..........done: 36,538 bytes
9 source files, building
running: phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
cp: impossibile eseguire stat di 'ltmain.sh': File o directory non esistente
building in /tmp/pear/temp/pear-build-rootVQ1eHL/mailparse-2.1.6
running: /tmp/pear/temp/mailparse/configure
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib
checking for PHP extension directory... /usr/lib/php5/20131226
checking for PHP installed headers prefix... /usr/include/php5
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... nawk
....
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
sed: can't read /tmp/pear/temp/mailparse/ltmain.sh: No such file or directory
mv: cannot stat 'libtoolT': No such file or directory
cp: cannot stat 'libtoolT': No such file or directory
chmod: cannot access 'libtool': No such file or directory
running: make
/bin/bash /tmp/pear/temp/pear-build-rootVQ1eHL/mailparse-2.1.6/libtool --mode=compile cc  -I. -I/tmp/pear/temp/mailparse -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootVQ1eHL/mailparse-2.1.6/include -I/tmp/pear/temp/pear-build-rootVQ1eHL/mailparse-2.1.6/main -I/tmp/pear/temp/mailparse -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/mailparse/mailparse.c -o mailparse.lo
/bin/bash: /tmp/pear/temp/pear-build-rootVQ1eHL/mailparse-2.1.6/libtool: File o directory non esistente
Makefile:187: set di istruzioni per l'obiettivo "mailparse.lo" non riuscito
make: *** [mailparse.lo] Errore 127
ERROR: `make' failed

utf-8 convert

problem in utf-8 language ( like persian )
subject is 'عنوان'
but return '=?UTF-8?B?2LnZhtmI2KfZhg==?='
how can i convert that?

Loosly coupled attachment class

Hi,

I would to extend the attachment with some specific logic. The attachments are tightly coupled atm.
I would be awesome if I could extend the attachment class in some kind of way

Thanx in advance

Filename of one attachment is not correctly decoded

According to http://dogmamix.com/MimeHeadersDecoder/

The content Type :

Content-Type: application/pdf; name=
"=?iso-8859-1?Q?50032266_CAR_11=5FMNPA00A01=5F9PTX=5FH00_ATT_N=B0_1467829.?=
=?iso-8859-1?Q?pdf?="
Content-Description: =?iso-8859-1?Q?50032266_CAR_11=5FMNPA00A01=5F9PTX=5FH00_ATT_N=B0_1467829.?=
=?iso-8859-1?Q?pdf?=
Content-Disposition: attachment; filename=
"=?iso-8859-1?Q?50032266_CAR_11=5FMNPA00A01=5F9PTX=5FH00_ATT_N=B0_1467829.?=
=?iso-8859-1?Q?pdf?="; size=631148;
creation-date="Fri, 14 Mar 2014 08:48:19 GMT";
modification-date="Fri, 14 Mar 2014 09:51:55 GMT"
Content-Transfer-Encoding: base64

Resulting
"50032266 CAR 11_MNPA00A01_9PTX_H00 ATT N° 1467829.pdf"

But your lib add unwanted underscore instead space :
"50032266_CAR_11_MNPA00A01_9PTX_H00_ATT_N°_1467829.pdf"

ks_c_5601-1987

I had this bug :

iconv(): Wrong charset, conversion from ks_c_5601-1987' toUTF-8//TRANSLIT' is not allowed

I found that : http://lccy.fr/mot/iconv/

The mail is below (I tried to anonymized it)

Return-Path: <[email protected]>
Delivered-To: [email protected]
Received: from spool.mail.gandi.net (mspool3-d.mgt.gandi.net [10.0.21.134])
    by nmboxes39-dc2.mgt.gandi.net (Postfix) with ESMTP id 40A5341A14
    for <[email protected]>; Mon, 20 Oct 2014 09:21:33 +0200 (CEST)
Received: from mfilter41-d.gandi.net (mfilter41-d.gandi.net [217.70.178.173])
    by spool.mail.gandi.net (Postfix) with ESMTP id 2391E116028
    for <[email protected]>; Mon, 20 Oct 2014 09:21:33 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mfilter41-d.gandi.net
Received: from spool.mail.gandi.net ([10.0.21.134])
    by mfilter41-d.gandi.net (mfilter41-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024)
    with ESMTP id N0YY2h2Co5jP for <[email protected]>;
    Mon, 20 Oct 2014 09:21:30 +0200 (CEST)
X-Policy: Greylisted 300 seconds
Received: from SRKREX01.kr.company.com (unknown [121.135.255.230])
    by spool.mail.gandi.net (Postfix) with ESMTPS id 8D33E11603E
    for <[email protected]>; Mon, 20 Oct 2014 09:21:04 +0200 (CEST)
Received: from SRKREX01.kr.company.com ([::1]) by
 SRKREX01.kr.company.com ([::1]) with mapi id 14.03.0123.003; Mon, 20 Oct
 2014 16:15:28 +0900
From: =?ks_c_5601-1987?B?wMzH/cH4?= <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [Korea] Name
Thread-Topic: [Korea] Name
Thread-Index: Ac/sNZ9vB8OV+HYiT9e1JOdEtk0N6w==
Date: Mon, 20 Oct 2014 07:15:27 +0000
Message-ID: <[email protected]>
Accept-Language: ko-KR, en-US
Content-Language: ko-KR
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator:
Content-Type: multipart/mixed;
    boundary="_003_7B2F0B047286488B990BD2EE3759554Dcompanykoreacokr_"
MIME-Version: 1.0

--_003_7B2F0B047286488B990BD2EE3759554Dcompanykoreacokr_
Content-Type: text/plain; charset="ks_c_5601-1987"
Content-ID: <[email protected]>
Content-Transfer-Encoding: base64

TXkgdHJhdmVsaW5nIGNvbXBhbmlvbnMhDQpNeSBmcmllbmQsIExlIFBsaWFnZSEgDQoNCg==

--_003_7B2F0B047286488B990BD2EE3759554Dcompanykoreacokr_
Content-Type: image/jpeg; name="=?ks_c_5601-1987?B?u+fB+C5KUEc=?="
Content-Description: =?ks_c_5601-1987?B?u+fB+C5KUEc=?=
Content-Disposition: attachment;
    filename="=?ks_c_5601-1987?B?u+fB+C5KUEc=?="; size=431635;
    creation-date="Mon, 20 Oct 2014 07:15:26 GMT";
    modification-date="Mon, 20 Oct 2014 07:15:26 GMT"
Content-ID: <[email protected]>
Content-Transfer-Encoding: base64

/9J/4AAQSKZJRGABAQAAAQABAAD/2WBDAAKGBWGHBGKIBWGKCGKLDRYPDQWMDRSUFRAWIB0IIIAD
HX8KKDQSJCYXJX8FLT0TMTU3OJO6IYS/RD84QZQ5OJF/2WBDAQOKCG0MDROPDXO3JR8LNZC3NZC3
NZC3NZC3NZC3NZC3NZC3NZC3NZC3NZC3NZC3NZC3NZC3NZC3NZC3NZC3NZF/WAARCABEAI0DASIA
AHEBA

--_003_7B2F0B047286488B990BD2EE3759554Dcompanykoreacokr_
Content-Type: text/plain; name="ATT00001.txt"
Content-Description: ATT00001.txt
Content-Disposition: attachment; filename="ATT00001.txt"; size=25;
    creation-date="Mon, 20 Oct 2014 07:15:27 GMT";
    modification-date="Mon, 20 Oct 2014 07:15:27 GMT"
Content-ID: <[email protected]>
Content-Transfer-Encoding: base64

DQoNCg0Kc2VudCBmcm9tIG15IGlQaG9uZQ==

--_003_7B2F0B047286488B990BD2EE3759554Dcompanykoreacokr_--

Splitting email address

From Your code you get from or to like name <email>. I think You can split it to array like

array(
    'name'=>'name',
    'email'=>'email'
);

Here is code to do that (from http://stackoverflow.com/questions/16685416/split-full-email-addresses-into-name-and-email)

private function email_split($str) {
        $str .=" ";
        $sPattern = '/([\w\s\'\"]+[\s]+)?(<)?(([\w-\.]+)@((?:[\w]+\.)+)([a-zA-Z]{2,4}))?(>)?/';
        preg_match($sPattern, $str, $aMatch);
        $name = (isset($aMatch[1])) ? $aMatch[1] : '';
        $email = (isset($aMatch[3])) ? $aMatch[3] : '';
        return array('name' => trim($name), 'email' => trim($email));
    }

decodeCharset() fails with certain charsets

I found that many emails were causing this error ...

PHP Notice:  iconv(): Detected an illegal character in input string in /Users/test/public_html/email/parse/MimeMailParser.class.php on line 382

... and that for these emails, $e->getMessageBody('text'); would be empty, but otherwise fine.

It was also inconsistent between my test server (running PHP 5.4) and the live server (running PHP 5.5), which was odd. PHP 5.5 showed a blank message body, PHP 5.4 worked correctly. But I eventually found http://stackoverflow.com/a/11303410/864908 which led me to modify MimeMailParser.class.php's decodeCharset function like so ...

private function decodeCharset($encodedString, $charset) {
    return ($charset == 'us-ascii') ? $encodedString : iconv($charset, 'UTF-8//TRANSLIT', $encodedString);
}

... and email bodies are appearing fine, and the errors have stopped. Apparently iconv doesn't properly handle encoding something that is already encoded. Or something. Anyways, I doubt my fix is perfect, but it solves my problems.

Below is an example of a problematic raw email. You'll see that the "Content-Type:" doesn't declare a charset ... but the script (or Mailparse) somehow assigns us-ascii, and iconv can't handle it. That's my best guess.

Is there a better solution?

~~

From [email protected] Tue Oct 01 00:42:20 2013
Received: from testsite.com ([255.255.255.255]:57350)
by testsite.com with esmtps (TLSv1:DHE-RSA-AES256-SHA:256)
(Exim 4.80.1)
(envelope-from [email protected])
id 1VQmAV-0004gO-Su
for [email protected]; Tue, 01 Oct 2013 00:42:20 +0200
Received: from ce-gw1.ogone.com ([255.255.255.255]:30117)
by testsite.com with esmtp (Exim 4.80.1)
(envelope-from [email protected])
id 1VQmAU-00007t-DO
for [email protected]; Tue, 01 Oct 2013 00:42:18 +0200
Received: from ([127.0.0.1]) with MailEnable ESMTP; Tue, 1 Oct 2013 00:42:18 +0200
From: "Ogone" [email protected]
Subject: Ogone NIEUWE order Maurits PAYID: 951597484 / orderID: 456123 /
status: 5
To: [email protected]
Content-Type: text/plain
Content-Transfer-Encoding: 8bit
Date: Tue, 1 Oct 2013 00:42:18 +0200
X-Priority: 3
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - testsite.com
X-AntiAbuse: Original Domain - testsite.com
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - ogone.com
X-Get-Message-Sender-Via: testsite.com: mailgid no entry from get_relayhosts_entry
X-Spam-Status: No, score=0.8
X-Spam-Score: 8
X-Spam-Bar: /
X-Spam-Flag: NO


  • Uw bestelgegevens:

Besteldatum : 01/10/2013 0:39:43
Referentie van de bestelling : 456123
Ogone Betaalreferentie : 951597484

Begunstigde : Test Site
PSPID : MyPSPID

Status : 25 Geautoriseerd
Autorisatiecode : 987321
UID : 1001052003337298
TID : 95227541

Totaal : 148.43 EUR

Aanrekeningmethode : VISA XXXXXXXXXXXX1111
Submerk : VISA
Vervaldatum : 10/15

Gegevens van de koper

Klant : First Last
Adres : 57 rue du Vignière
Postcode : 12260
Plaats : SelongeyCotedor
Land : FR
Telefoonnummer : 0625551212

Deze transactie moet manueel bevestigd worden in de beheer module voor een betaling te genereren.

De koper werd met succes ge

Parser::getPartCharset else condition

The else condition Parser::getPartCharset seems odd. The else is only reached if $part['charset'] is not set. But it is still used in the getCharsetAlias call.

wrong parsing "recipient" (my working code)

function extract_email_address ($string) {
foreach(preg_split('/\s/', $string) as $token) {
$email = filter_var(filter_var($token, FILTER_SANITIZE_EMAIL), FILTER_VALIDATE_EMAIL);
if ($email !== false) {
$emails[] = $email;
}
}
return $emails;
}
//The check if a letter has many recipients
$address_array = imap_rfc822_parse_adrlist($to, "example.com");
$from = imap_rfc822_parse_adrlist($from, "example.com");
// check if my domain
$domain_base_array = array(
'exemple1.com' => "my_1_domain",
'exemple2.com' => "my_domainsecond",
'exemple3.com' => "I_wner_of_letter",
);

foreach ($address_array as $key_name => $value111){
$toaddres_host=$value111->host;
$toaddres_usr=$value111->mailbox;
$name=$value111->personal;
$decode = imap_mime_header_decode($text);
//$name=convert_chars($decode[0]->charset,$decode[0]->text);
$toaddres=$value111->mailbox."@".$value111->host;
$table_name = $domain_base_array[$toaddres_host];
if (isset($table_name)){
$ADRESSAT="yes";
}else{

$email_to=extract_email_address($Parser->parts[1][headers][received][0]);

$email_to_arr=explode('@', $email_to[0]);
$toaddres_usr=$email_to_arr[0];
$toaddres_host=$email_to_arr[1];
$toaddres=$email_to['0'];
$table_name = $domain_base_array[$toaddres_host];
if (isset($table_name)){
$ADRESSAT="yes";
}else{$ADRESSAT="not";}
}

PECL mailparse package not available

Hi,

mailparse can not be installed from PECL because of this error:

No releases available for package "pecl.php.net/mailparse"

Running on:
Windows 8
XAMPP
PHP 5.6.8 (cli) (built: Apr 15 2015 15:07:09)

Combining split messages

Hi, some scanners split messages at a certain amount of Mb. Usually you can influence this, but not always. In the mail header I can see Content-Type: message/partial; number=1; total=2; id="[email protected]"

The other part contains of course number=2; total=2

is there functionality to recognise this and combine the two messages?

Regs,
Peter

I can't install mailparse

Hi all,

Sorry for this issue, but i'm trying to install mailparse extension without success :

See below my test :

docker run -it --rm php:5.6-cli bash

root@3cbcf6168f3e:/# docker-php-ext-configure mbstring

root@3cbcf6168f3e:/# docker-php-ext-install mbstring

mbstring is enabled :

root@3cbcf6168f3e:/# php -m | grep 'mbstring'
mbstring

But :

root@3cbcf6168f3e:/# pecl install mailparse
pecl/mailparse requires PHP extension "mbstring"
No valid packages found
install failed

trying too without success :

root@3cbcf6168f3e:/# pear install pecl/mailparse
downloading mailparse-2.1.6.tgz ...
Starting to download mailparse-2.1.6.tgz (36,538 bytes)
..........done: 36,538 bytes
9 source files, building
running: phpize

[......]

running: make
/bin/bash /tmp/pear/temp/pear-build-defaultuser9zXP1p/mailparse-2.1.6/libtool --mode=compile cc  -I. -I/tmp/pear/temp/mailparse -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuser9zXP1p/mailparse-2.1.6/include -I/tmp/pear/temp/pear-build-defaultuser9zXP1p/mailparse-2.1.6/main -I/tmp/pear/temp/mailparse -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/mailparse/mailparse.c -o mailparse.lo
mkdir .libs
 cc -I. -I/tmp/pear/temp/mailparse -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuser9zXP1p/mailparse-2.1.6/include -I/tmp/pear/temp/pear-build-defaultuser9zXP1p/mailparse-2.1.6/main -I/tmp/pear/temp/mailparse -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/mailparse/mailparse.c  -fPIC -DPIC -o .libs/mailparse.o
/tmp/pear/temp/mailparse/mailparse.c:34:2: error: #error The mailparse extension requires the mbstring extension!
 #error The mailparse extension requires the mbstring extension!
  ^
Makefile:187: recipe for target 'mailparse.lo' failed
make: *** [mailparse.lo] Error 1
ERROR: `make' failed

I've seen a issue about that but i dont know if is always active : https://support.zend.com/hc/en-us/articles/203408233-Compile-mailparse-extension-with-mbstring-dependency-

Thx for replies,
Best regards,

Can't install with Composer

Bonjour,
I currently work with a server that does not allow execution of phar files, so even after installing Composer I can't make it install your parser. I have attempted to call the parser directly from my script but it fails when attempting to create an instance of Charset.
I have tried adding a new 'use' line on Parser.php pointing to Charset, but still I get back a 'class not found' error.

Desole de vous ennuiyer avec ce probleme. (Excusez-moi aussi pour la manque d'accents.. ce clavier est Americain).

Merci

Pedro Maldonado

Class 'eXorus\PhpMimeMailParser\Parser' not found

Running PHP 5.5.9, Ubuntu 14.04, latest stable Composer with everything freshly installed and configured according to the Readme.

I was using the old autoload.php before, but now after switching to autoload_psr4.php and updating your mail parser, I can't seem to get autoloading working for your library.

I've removed composer, vendor folder and everything else that I thought could have caused this, but still, nada.

Any tips on how to proceed?

composer zipball url

Composer is trying to download the zipball from here: https://api.github.com/repos/eXorus/php-mime-mail-parser/zipball/c6d091937f178be9f38d2ce187faab86b19a4f61
This doesn't work, and sometimes composer update/install crashes, sometimes it falls back to cloning the repo. Fortunately cloning still works (github has a redirect for that).

I think you need to change the repo url in composer.json: https://github.com/php-mime-mail-parser/php-mime-mail-parser/blob/master/composer.json#L42

forward parsed mail

I know this isn't exactly the purpose of a mime-mail-parser library, but did anyone ever tried to forward a parsed mail? I'm basically just trying to fetch a mail by POP3/IMAP and then forward it to another account.

Any pointers appreciated! I know that I could parse each part but I'm looking for a more raw solution to ensure that I don't break the mail or miss a part.

saveAttachments() doesn't work if attachment filename is invalid

Here is an example of the problematic part.

------=_NextPart_001_0037_01D030B5.2C012230
Content-Type: image/jpeg;
    name="32891_G_front.jpg?sw=78&sh=78&sfrm=jpg"
Content-Transfer-Encoding: base64
Content-Location: https://sits-pod24.demandware.net/dw/image/v2/AATB_PRD/on/demandware.static/Sites-hrzfr-Site/Sites-hz-master-catalog/fr_FR/v1418396680606/Malouk/32891_G_front.jpg?sw=78&sh=78&sfrm=jpg

/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcU
FhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgo
KCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCABOAE4DASIA
AhEBAxEB/8QAHAABAAMAAwEBAAAAAAAAAAAAAAYHCAEEBQMC/8QANBAAAQMDAgQFAwIFBQAAAAAA
AQIDBAAFEQYhBxIxQRMUUWFxIjKBCEIVIyRisZGhosHR/8QAGQEAAwEBAQAAAAAAAAAAAAAAAAME
AgEF/8QAIxEAAgIBBAICAwAAAAAAAAAAAAECAxEEEiExE1EjQSKhsf/aAAwDAQACEQMRAD8A1TSl
KAFKUoAg3FHUV5tUeDbtLxS/dp6l/wA3lBTHaQBzLIO2clKRnbJ9qypqniDxK0jqOO5crvdY88/W
piQeaOtIOwCftI9cf6itfax5mXoL7LHiOFRbUQCSEHB/G+Kq/ihaG9VWObEnwm/DbCiy+pJy2obA
pUe+ew7daktv2Tw+j0KNMrK012Wnw71O1rHRdpvzKA35xkKW2P2OA8q0/hQP4qR1W/6erTIsvCy1
QpYw8lTqj6brJ29qsiqYvck0Qzi4ycWKUpWjIpSlAClK8TV93nWazPzLZbDc3mUlamQ6GzygZJGx
yfYCgDocR5y7ZYUzQ1zssuhT6hkqbawcrAHUDYkemT2qmtcaoSNNSW4EyPMkFCnk+Xc8QIBB+pR+
TsNqimpeMeoL3MX4yYyLapCml28JJbcQoYPMrIUSR3BGO1RjQT7DMu429HMxa5CQstuEOKb+tIOF
YBKRkbYzj43m1NDkty7PQ0mp8a8b+yd/pw4mSrTHg6ZvSHZUR9f9O+hJW60tZyQoDJUnJO/UfHTU
1YUs2trjprVMi4aVjx4rZ5mwqQ0HVKBO5GccoJGwG4B3JrWvCLWDus9Hx585DTc9K1tPBsYSopOO
YDtkY2qn6IpLkm1KUoMClKEhIJJwBuSaAPhOlIhxy65k7gADqSa6jktlLYdUtJaO5V61HL5d0vO8
4Clo5vDYbSMqWo+g9TX6XpJyZYJjc2Q63PfCXGi0s8sZaTzIx6kKAye/TpSIWuc2o9Fk6FVWnN8s
yJqWG1F1Rc4QUlttqY60lSsgJSHDjPtjFerBsVxsD8K7c8RaVOJQhtSlEuBZ5BgYGUnOQc9qjl0f
lS58yVcDzS33luvKAwOdSiTt23rruXGWY6GVSXlNNfUhBWSlJG4wKoaZOdiRapDTkxDnIlUZxbS+
ZYBKkqwRjrV9/pvntw4TMF19AefecUlsHJIO/bp9tUlr51J1neXEgYU+XD8kBSv9yasix293RGqt
LBZUTLhxphGOhP3j8bikXzcUmvZRp4KbcX6NTUoOlKcRiujfW5Dtpkohp531JwlOcZ33GfjNd6lc
aysHYy2tMri0PNMXVl95o+bjgpLTuQU52Jx2OO/uankW4xpIAQ4As/tVsa4uFsh3DHm2ELUn7V9F
D4I3qF63ft2kokWRImKQJL6Y7aHSDuQd8+gx19xU0YTpTxyi+dlWpa3cS/RlviGmInXF+TbyfKia
7yDGw+s5x7ZzUetsZU65xIqfukyG2E/KlAf91c3GN2x+VgibHT5uQohLkYJS8lIH3nspIO2D1zsQ
RVV6GKHNc2goOWo8jxAT35AVk/8AGqK7PJHOMCLqvFLbnJ9BFVqDXRio3M65eCPhTvL/AIrVGv7Q
LjqOyRo6EhSWy2nA+1JP+AAaynoy4mBqy1TQopeakIcQeUKHOTtnPQZOc+1a/wBDMXOa8m63hKgS
zyM+KMLOTurHYY2Hek3/AJ/H7GU/Gndnr+kzSOVIA6DauaUqgiFKUoAVnzj/AKW1Teb1/EIrCp9o
jthLbMb6ls7ZWSjqcnuM7AdK0HXmOKw+6P7qM4NRMIXqTNnTFOXBTokhCW+V3IUhIGAnB3GK9TQD
aG706sjCWIEx3PuI6/8A2tZ6zsNrvEVS7lAjyHEDIWtsFQ/PWq0XoWyqCnoLHlC4ktr8MkBaFfck
jPQjasSsUeMD41uazkqrgnbHLnxIs+G0OIjueZUhachSUJyRj19PettioBwutjFlaejMMMIS4OYK
bbCSMdvip/XYPKyKtW2WBSlK0LP/2TwhRE9DVFlQRSBIVE1MIFBVQkxJQyAiLS8vSUVURi8vRFRE
IEhUTUwgMi4wLy9FTiI+CjxodG1sPjxoZWFkPgo8dGl0bGU+MjAwIE9LPC90aXRsZT4KPC9oZWFk
Pjxib2R5Pgo8aDE+T0s8L2gxPgo8cD5UaGUgc2VydmVyIGVuY291bnRlcmVkIGFuIGludGVybmFs
IGVycm9yIG9yCm1pc2NvbmZpZ3VyYXRpb24gYW5kIHdhcyB1bmFibGUgdG8gY29tcGxldGUKeW91
ciByZXF1ZXN0LjwvcD4KPHA+UGxlYXNlIGNvbnRhY3QgdGhlIHNlcnZlciBhZG1pbmlzdHJhdG9y
IGF0IAogc3VwcG9ydEBkZW1hbmR3YXJlLmNvbSB0byBpbmZvcm0gdGhlbSBvZiB0aGUgdGltZSB0
aGlzIGVycm9yIG9jY3VycmVkLAogYW5kIHRoZSBhY3Rpb25zIHlvdSBwZXJmb3JtZWQganVzdCBi
ZWZvcmUgdGhpcyBlcnJvci48L3A+CjxwPk1vcmUgaW5mb3JtYXRpb24gYWJvdXQgdGhpcyBlcnJv
ciBtYXkgYmUgYXZhaWxhYmxlCmluIHRoZSBzZXJ2ZXIgZXJyb3IgbG9nLjwvcD4KPC9ib2R5Pjwv
aHRtbD4K

------=_NextPart_001_0037_01D030B5.2C012230--

Maybe you will be interested in this as well.

X-Mailer: Microsoft Windows Mail 6.0.6002.18197
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18463

attachment size

Hi,

First of all you made a great library.
In the attachment class I would like a method that returns the size of an attachment.

Let me know what you think.

Namespace and class "Exception" not found

Hi,
When reaching a line throwing an exception, the following error occurs :

Fatal error: Class 'eXorus\PhpMimeMailParser\Exception' not found in (...)

Some quick research on the Web tends to show that calling class "Exception" along with "namespace eXorus\PhpMimeMailParser;" will make PHP search for class "eXorus\PhpMimeMailParser\Exception"; which seems pretty logical.

Adding a backslash before class name makes PHP search in default namespace, and solves the problem :

throw new \Exception (...)

I suppose the code you wrote works for you, but then... what am I missing ?
I'm using PHP v5.6.16 on Ubuntu

Thanks in advance,
Mathias

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.