1: <?php
2: 3: 4: 5:
6: class Horde_Core_Factory_Mail extends Horde_Core_Factory_Injector
7: {
8: public function create(Horde_Injector $injector)
9: {
10: $transport = isset($GLOBALS['conf']['mailer']['type'])
11: ? $GLOBALS['conf']['mailer']['type']
12: : 'null';
13: $params = isset($GLOBALS['conf']['mailer']['params'])
14: ? $GLOBALS['conf']['mailer']['params']
15: : array();
16:
17: if ((strcasecmp($transport, 'smtp') == 0) &&
18: $params['auth'] &&
19: empty($params['username'])) {
20: $params['username'] = $GLOBALS['registry']->getAuth();
21: $params['password'] = $GLOBALS['registry']->getAuthCredential('password');
22: }
23:
24: $class = 'Horde_Mail_Transport_' . ucfirst($transport);
25: if (class_exists($class)) {
26: $ob = new $class($params);
27:
28: if (!empty($params['sendmail_eol']) &&
29: (strcasecmp($transport, 'sendmail') == 0)) {
30: $ob->sep = $params['sendmail_eol'];
31: }
32:
33: return new $class($params);
34: }
35:
36: throw new Horde_Exception('Unable to find class for transport ' . $transport);
37: }
38:
39: }
40: