Author Topic: Send e-mail from the plugin  (Read 4100 times)

0 Members and 1 Guest are viewing this topic.

Gori

  • Jr. Member
  • **
  • Posts: 1
Send e-mail from the plugin
« on: November 09, 2015, 08:46:29 AM »
Hi,

is there an easy way to send an e-mail from plugin? I'd like to use public function sendMail from AbstractController.php, but don't know how.
Please just suggest me which classes to use and how to call that function. Tried to find something useful in docu and sources, but nothing works for me.

Thanks in advance

Jirka

Dmitriy Simushev

  • Moderator
  • Native
  • *****
  • Posts: 345
Re: Send e-mail from the plugin
« Reply #1 on: November 09, 2015, 01:16:51 PM »
Hi,

At the moment plugins can be used in two separate ways:
  1. As an event listeners.
  2. As producers and handlers of routes.

If you're talking about the first way, then I really don't think that you could easily add emails sending. You see, plugins in Mibew do not get an instance of
Code: [Select]
\Mibew\Mail\MailerFactoryInterface that is used to send messages in controllers. (It seems to be an architecture flaw but I don't see a simple way to fix it.) At the same time, you could create an instance of this class by yourself in the plugin.

If you're talking about the second way, you could just use
Code: [Select]
$this->sendMail(...) in your controllers.