What email analysis can I use with Composer?

table of contents
Hello,
I'm Mandai, the Wild Team member of the development team.
When analyzing emails in PHP, the traditional approach is to use PEAR's Mail class, which is a bit tedious but quick. However, these days I find email analysis itself to be a hassle, so I looked into email analysis libraries that can be installed from composer to see if there was anything better
php-mime-mail-parser
I'm not sure if it's the most popular, but php-mime-mail-parser seems to be a commonly used library
This is a library that uses mailparse and is released as a PECL extension for PHP, so it is likely to be quite fast
The disadvantage is that mailparse is installed additionally, so you will need to edit php.ini to install it, which will require a restart
Since only the parser functionality is provided, if you want to send emails, you will need to consider the delivery part separately using a library or your own implementation
github , you'll understand how to use it, and I think it's very straightforward to use.
# Install from composer composer require php-mime-mail-parser/php-mime-mail-parser
mailparse can be downloaded from https://pecl.php.net/package/mailparse
zetacomponents/mail
zetacomponents/mail has a wide range of email-related functions, and since it can also be used for delivery, I think most email implementations can be achieved using this library
In terms of speed, since it is implemented in pure PHP, it is likely to be at a disadvantage compared to the php-mime-mail-parser mentioned earlier
It is developed as a module of Zeta Components
When I tried using it, I found it to be less straightforward than php-mime-mail-parser and had some quirks.
If you just want to parse emails, I think it would be better to use php-mime-mail-parser.
# Install from composer composer require zetacomponents/mail
pear/mail
You can install PEAR packages from composer!
It seems like a direct contradiction to the intro text, but since it can be installed using composer, it's not a problem for blogging!
In fact, it's a good surprise.
I haven't been implementing this kind of thing recently (that's my excuse), so I didn't know this, but PEAR packages require PEAR core modules and cannot be installed on their own, making installation a hassle (to be honest). However, if you use composer, it will install the minimum packages for PEAR core modules as dependencies
The biggest advantages of using pear/mail are that your previous knowledge is still useful, it's an outdated library so there are few bugs, and it targets PHP versions 5.2.1 and above, so it works anywhere.
If you can install it from composer, this might be the only option...
# Install from composer composer require pear/mail
summary
Personally, I would like to recommend php-mime-mail-parser, but I have to say that the requirement of the PECL extension makes it a bit difficult to get started.
zetacomponents/mail and pear/mail do not require any additional extensions, so the barrier to entry is much lower.
Personally, I find installing PEAR more troublesome than installing PECL, so I'm very pleased that pear/mail can now be installed from composer.
Furthermore, zetacomponents/mail is tricky to use and doesn't feel very modern, which is the same as pear/mail
What struck me was that composer is not necessarily going to replace PEAR
Each email analysis library has its pros and cons, but I felt that I wanted to use one that suited my requirements
That's all
1