xref: /plugin/smtp/classes/Message.php (revision 0b7ac7c9b23c9f486d917d495bb59e3d5f16cd88)
1*0b7ac7c9SAndreas Gohr<?php
2*0b7ac7c9SAndreas Gohr
3*0b7ac7c9SAndreas Gohrnamespace splitbrain\dokuwiki\plugin\smtp;
4*0b7ac7c9SAndreas Gohr
5*0b7ac7c9SAndreas Gohr/**
6*0b7ac7c9SAndreas Gohr * Class Message
7*0b7ac7c9SAndreas Gohr *
8*0b7ac7c9SAndreas Gohr * Overrides the Message class with what we need to reuse the SMTP mailer without using
9*0b7ac7c9SAndreas Gohr * their message composer
10*0b7ac7c9SAndreas Gohr *
11*0b7ac7c9SAndreas Gohr * @package splitbrain\dokuwiki\plugin\smtp
12*0b7ac7c9SAndreas Gohr */
13*0b7ac7c9SAndreas Gohrclass Message extends \Tx\Mailer\Message {
14*0b7ac7c9SAndreas Gohr
15*0b7ac7c9SAndreas Gohr    protected $from;
16*0b7ac7c9SAndreas Gohr    protected $to;
17*0b7ac7c9SAndreas Gohr    protected $body;
18*0b7ac7c9SAndreas Gohr
19*0b7ac7c9SAndreas Gohr    /**
20*0b7ac7c9SAndreas Gohr     * @param $from
21*0b7ac7c9SAndreas Gohr     * @param $to
22*0b7ac7c9SAndreas Gohr     * @param $body
23*0b7ac7c9SAndreas Gohr     */
24*0b7ac7c9SAndreas Gohr    public function __construct($from, $to, $body) {
25*0b7ac7c9SAndreas Gohr        $this->from = $from;
26*0b7ac7c9SAndreas Gohr        $this->to = $to;
27*0b7ac7c9SAndreas Gohr        $this->body = $body;
28*0b7ac7c9SAndreas Gohr    }
29*0b7ac7c9SAndreas Gohr
30*0b7ac7c9SAndreas Gohr    /**
31*0b7ac7c9SAndreas Gohr     * @return string
32*0b7ac7c9SAndreas Gohr     */
33*0b7ac7c9SAndreas Gohr    public function getFromEmail() {
34*0b7ac7c9SAndreas Gohr        return $this->from;
35*0b7ac7c9SAndreas Gohr    }
36*0b7ac7c9SAndreas Gohr
37*0b7ac7c9SAndreas Gohr    /**
38*0b7ac7c9SAndreas Gohr     * @return array
39*0b7ac7c9SAndreas Gohr     */
40*0b7ac7c9SAndreas Gohr    public function getTo() {
41*0b7ac7c9SAndreas Gohr        $rcpt = explode(',', $this->to); //FIXME this needs to be improved
42*0b7ac7c9SAndreas Gohr        $rcpt = array_filter($rcpt);
43*0b7ac7c9SAndreas Gohr        $rcpt = array_unique($rcpt);
44*0b7ac7c9SAndreas Gohr        return $rcpt;
45*0b7ac7c9SAndreas Gohr    }
46*0b7ac7c9SAndreas Gohr
47*0b7ac7c9SAndreas Gohr    /**
48*0b7ac7c9SAndreas Gohr     * @return string
49*0b7ac7c9SAndreas Gohr     */
50*0b7ac7c9SAndreas Gohr    public function toString() {
51*0b7ac7c9SAndreas Gohr        // FIXME we need to remove the BCC fields here
52*0b7ac7c9SAndreas Gohr
53*0b7ac7c9SAndreas Gohr        return $this->body . $this->CRLF . $this->CRLF . "." . $this->CRLF;
54*0b7ac7c9SAndreas Gohr    }
55*0b7ac7c9SAndreas Gohr
56*0b7ac7c9SAndreas Gohr}
57