What email analysis can I use with Composer?

table of contents
Hello.
I'm Mandai, the Wild team member in charge of development.
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
the GitHubdocumentation, but I think it's great because it's very straightforward to use.
# Install from composer composer require php-mime-mail-parser/php-mime-mail-parser
mailparsehttps://pecl.php.net/package/mailparsecan be downloaded from
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
Zeta ComponentsIt's deployed as a module in
After trying it out, I found it wasn't as straightforward as php-mime-mail-parser, and it had a few quirks.
If you only need to parse emails, I think php-mime-mail-parser is probably the better option.
# Install from composer composer require zetacomponents/mail
pear/mail
You can install PEAR packages from composer!
It might seem to directly contradict the introductory text, but since it can be installed using Composer, it's not a problem from a blog perspective!
In fact, it's surprisingly good.
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 existing knowledge is directly applicable, it's a mature library with few bugs, and it works everywhere because it targets PHP version 5.2.1 or higher.
If you can install it via Composer, then this might be the only option...
# Install from composer composer require pear/mail
summary
Personally, I'd recommend php-mime-mail-parser, but the fact that it requires a PECL extension makes it a bit of a hassle to adopt.
zetacomponents/mail and pear/mail don't require any additional extensions, so their barriers to adoption are significantly lower.
Personally, I find installing PEAR more troublesome than installing PECL, so the fact that pear/mail can now be installed via Composer is a big plus.
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
