mtymek / MtMail

Module for composing e-mails from templates and sending them
BSD 2-Clause "Simplified" License
18 stars 14 forks source link

DefaultHeaders plugin no longer working after ZF3 upgrade #41

Open Erikvv opened 6 years ago

Erikvv commented 6 years ago

I updated my project, mostly zend-servicemanager and zend-eventmanager from v2 to v3, and now the From header is missing.

Zend\Mail\Transport\Smtp transport expects either a Sender or at least one From address in the Message; none provided

MtMail version is the same (1.5.1). If i set the header manually it works.

I'm not sure whats going on. Will investigate a bit more.

Erikvv commented 6 years ago

Classes Composer and DefaultHeaders are using different instances of the EventManager

Erikvv commented 6 years ago

The first instance Composer makes for itself in its factory at https://github.com/mtymek/MtMail/blob/master/src/Factory/ComposerServiceFactory.php#L41

Then after this the ServiceManager calls Composer::setEventManager() because of EventManagerAwareInterface

I think the best solution is to remove EventManagerAwareInterface and remove setEventManager

Erikvv commented 6 years ago

This has the same root cause as https://github.com/mtymek/MtMail/issues/36