What kind of email analysis can be used with Composer?
table of contents
Hello.
I'm Mandai, in charge of Wild on the development team.
When parsing emails with PHP, the classical method is to use PEAR's Mail class, which is a quick but tedious method, and these days when email analysis itself feels troublesome, there is nothing better. I looked into email analysis libraries that can be installed from composer.
php-mime-mail-parser
I don't know if it's the most popular library, but php-mime-mail-parser seems to be a commonly used library.
This is a library that uses mailparse, which is published as a PECL extension for PHP, so it seems to be fast.
The disadvantage is that since mailparse is additionally installed, php.ini needs to be edited for installation, so a restart is required.
Since it only provides the parser function, if you want to send emails, etc., you will need to consider the delivery part with a separate library or unique implementation.
the github documentation, but I think it would be nice to be able to use it in a very straightforward manner.
# 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 variety of email-related functions, but since you can also send emails using this library, I think most email implementations can be implemented using this library.
In terms of speed, it is implemented in pure PHP, so it seems to be at a disadvantage compared to the previous php-mime-mail-parser.
It is deployed as a Zeta Components
When I tried using it, it wasn't as straightforward as php-mime-mail-parser, and I felt it had some quirks.
If you only 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
PEAR packages can be installed from composer!
I feel like I'm directly denying the intro text, but it can be installed using composer, so it's not a problem from a blog perspective!
It's rather surprising.
I didn't know about it because I've been away from this kind of implementation recently (my excuse), but the PEAR package requires the PEAR core module and cannot be installed alone, so it's a pain to install (this is the real deal) However, if you use composer, the minimum package of PEAR's core module will also be installed as a dependency.
The biggest advantages of using pear/mail are that past knowledge is still useful, it is an old library, so there are few bugs, and the target PHP version is 5.2.1 or higher, so it works everywhere. .
If you can install it from composer, this may 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 for PECL extensions makes it a little difficult to implement.
Since zetacomponents/mail and pear/mail do not require any additional extensions, the implementation barrier is extremely low.
Personally, I think installing PEAR is more troublesome than installing PECL, so I'm very impressed with pear/mail, which can now be installed from composer.
Furthermore, pear/mail is also the same in that zetacomponents/mail is difficult to use and doesn't have a modern feel.
I was impressed by the fact that composer is not necessarily the one that will destroy PEAR.
Although email analysis libraries have their advantages and disadvantages, my impression was that I would like to use one that suits my requirements.
That's it.