[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

What kind of email analysis can be used with Composer?

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.

If you found this article helpful , please give it a like!
1
Loading...
1 vote, average: 1.00 / 11
2,804
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

The person who wrote this article

About the author

Yoichi Bandai

My main job is developing web APIs for social games, but I'm also fortunate to be able to do a lot of other work, including marketing.
Furthermore, my portrait rights in Beyond are treated as CC0 by him.