14dc22474SAndreas Gohr<?php 24dc22474SAndreas Gohr/** 34dc22474SAndreas Gohr * DokuWiki Plugin smtp (Action Component) 44dc22474SAndreas Gohr * 54dc22474SAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 64dc22474SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 74dc22474SAndreas Gohr */ 84dc22474SAndreas Gohr 94dc22474SAndreas Gohr// must be run within Dokuwiki 104dc22474SAndreas Gohrif(!defined('DOKU_INC')) die(); 114dc22474SAndreas Gohr 124dc22474SAndreas Gohrclass action_plugin_smtp extends DokuWiki_Action_Plugin { 134dc22474SAndreas Gohr 144dc22474SAndreas Gohr /** 154dc22474SAndreas Gohr * Registers a callback function for a given event 164dc22474SAndreas Gohr * 174dc22474SAndreas Gohr * @param Doku_Event_Handler $controller DokuWiki's event controller object 184dc22474SAndreas Gohr * @return void 194dc22474SAndreas Gohr */ 204dc22474SAndreas Gohr public function register(Doku_Event_Handler $controller) { 214dc22474SAndreas Gohr 22*0b7ac7c9SAndreas Gohr $controller->register_hook('MAIL_MESSAGE_SEND', 'BEFORE', $this, 'handle_mail_message_send'); 234dc22474SAndreas Gohr 244dc22474SAndreas Gohr } 254dc22474SAndreas Gohr 264dc22474SAndreas Gohr /** 274dc22474SAndreas Gohr * [Custom event handler which performs action] 284dc22474SAndreas Gohr * 294dc22474SAndreas Gohr * @param Doku_Event $event event object by reference 304dc22474SAndreas Gohr * @param mixed $param [the parameters passed as fifth argument to register_hook() when this 314dc22474SAndreas Gohr * handler was registered] 324dc22474SAndreas Gohr * @return void 334dc22474SAndreas Gohr */ 344dc22474SAndreas Gohr 354dc22474SAndreas Gohr public function handle_mail_message_send(Doku_Event &$event, $param) { 36*0b7ac7c9SAndreas Gohr require_once __DIR__ . '/loader.php'; 37*0b7ac7c9SAndreas Gohr 38*0b7ac7c9SAndreas Gohr /** @var Mailer $mailer Our Mailer with all the data */ 39*0b7ac7c9SAndreas Gohr $mailer = $event->data['mail']; 40*0b7ac7c9SAndreas Gohr $to = $event->data['to'].','.$event->data['cc'].','.$event->data['bcc']; 41*0b7ac7c9SAndreas Gohr $from = $event->data['from']; 42*0b7ac7c9SAndreas Gohr 43*0b7ac7c9SAndreas Gohr $message = new \splitbrain\dokuwiki\plugin\smtp\Message( 44*0b7ac7c9SAndreas Gohr $from, 45*0b7ac7c9SAndreas Gohr $to, 46*0b7ac7c9SAndreas Gohr $mailer->dump() 47*0b7ac7c9SAndreas Gohr ); 48*0b7ac7c9SAndreas Gohr 49*0b7ac7c9SAndreas Gohr $smtp = new \Tx\Mailer\SMTP(); 50*0b7ac7c9SAndreas Gohr $smtp->setServer('localhost', 2525, null); 51*0b7ac7c9SAndreas Gohr 52*0b7ac7c9SAndreas Gohr $smtp->send($message); 534dc22474SAndreas Gohr } 544dc22474SAndreas Gohr 554dc22474SAndreas Gohr} 564dc22474SAndreas Gohr 574dc22474SAndreas Gohr// vim:ts=4:sw=4:et: 58