xref: /dokuwiki/_test/tests/inc/mailer.test.php (revision 1d7c1f1bfdde1a689e622b5c475614fed4b553e1)
1cc92aca7SAndreas Gohr<?php
2cc92aca7SAndreas Gohr
3cc92aca7SAndreas Gohr/**
4cc92aca7SAndreas Gohr * Extends the mailer class to expose internal variables for testing
5cc92aca7SAndreas Gohr */
6cc92aca7SAndreas Gohrclass TestMailer extends Mailer {
7cc92aca7SAndreas Gohr    public function prop($name){
8cc92aca7SAndreas Gohr        return $this->$name;
9cc92aca7SAndreas Gohr    }
101f61f312SDominik Eckelmann
111f61f312SDominik Eckelmann    public function &propRef($name) {
121f61f312SDominik Eckelmann        return $this->$name;
131f61f312SDominik Eckelmann    }
141f61f312SDominik Eckelmann
151f61f312SDominik Eckelmann    public function prepareHeaders() {
161f61f312SDominik Eckelmann        return parent::prepareHeaders();
171f61f312SDominik Eckelmann    }
18b6c97c70SAndreas Gohr
19b6c97c70SAndreas Gohr    public function cleanHeaders() {
20b6c97c70SAndreas Gohr        parent::cleanHeaders();
21b6c97c70SAndreas Gohr    }
22b6c97c70SAndreas Gohr
23cc92aca7SAndreas Gohr}
24cc92aca7SAndreas Gohr
25cc92aca7SAndreas Gohrclass mailer_test extends DokuWikiTest {
26cc92aca7SAndreas Gohr
27cc92aca7SAndreas Gohr
28cc92aca7SAndreas Gohr    function test_userheader(){
29cc92aca7SAndreas Gohr        $mail = new TestMailer();
30cc92aca7SAndreas Gohr        $headers = $mail->prop('headers');
31cc92aca7SAndreas Gohr        $this->assertArrayNotHasKey('X-Dokuwiki-User',$headers);
32cc92aca7SAndreas Gohr
33cc92aca7SAndreas Gohr        $_SERVER['REMOTE_USER'] = 'andi';
34cc92aca7SAndreas Gohr        $mail = new TestMailer();
35cc92aca7SAndreas Gohr        $headers = $mail->prop('headers');
36cc92aca7SAndreas Gohr        $this->assertArrayHasKey('X-Dokuwiki-User',$headers);
37cc92aca7SAndreas Gohr    }
38cc92aca7SAndreas Gohr
39cc92aca7SAndreas Gohr    function test_setHeader(){
40cc92aca7SAndreas Gohr        $mail = new TestMailer();
41cc92aca7SAndreas Gohr
42cc92aca7SAndreas Gohr        // check existance of default headers
43cc92aca7SAndreas Gohr        $headers = $mail->prop('headers');
44cc92aca7SAndreas Gohr        $this->assertArrayHasKey('X-Mailer',$headers);
45cc92aca7SAndreas Gohr        $this->assertArrayHasKey('X-Dokuwiki-Title',$headers);
46cc92aca7SAndreas Gohr        $this->assertArrayHasKey('X-Dokuwiki-Server',$headers);
47cc92aca7SAndreas Gohr        $this->assertArrayHasKey('X-Auto-Response-Suppress',$headers);
48cc92aca7SAndreas Gohr        $this->assertArrayHasKey('List-Id',$headers);
49cc92aca7SAndreas Gohr
50cc92aca7SAndreas Gohr        // set a bunch of test headers
51cc92aca7SAndreas Gohr        $mail->setHeader('test-header','bla');
52cc92aca7SAndreas Gohr        $mail->setHeader('to','A valid ASCII name <test@example.com>');
53c8d2e830SChristopher Smith        $mail->setHeader('from',"Thös ne\needs\x00serious cleaning\$§%.");
54c8d2e830SChristopher Smith        $mail->setHeader('bad',"Thös ne\needs\x00serious cleaning\$§%.",false);
55cc92aca7SAndreas Gohr        $mail->setHeader("weird\n*+\x00foo.-_@bar?",'now clean');
56cc92aca7SAndreas Gohr
57cc92aca7SAndreas Gohr        // are they set?
58cc92aca7SAndreas Gohr        $headers = $mail->prop('headers');
59cc92aca7SAndreas Gohr        $this->assertArrayHasKey('Test-Header',$headers);
60cc92aca7SAndreas Gohr        $this->assertEquals('bla',$headers['Test-Header']);
61cc92aca7SAndreas Gohr        $this->assertArrayHasKey('To',$headers);
62cc92aca7SAndreas Gohr        $this->assertEquals('A valid ASCII name <test@example.com>',$headers['To']);
63cc92aca7SAndreas Gohr        $this->assertArrayHasKey('From',$headers);
64cc92aca7SAndreas Gohr        $this->assertEquals('Ths neeedsserious cleaning.',$headers['From']);
65cc92aca7SAndreas Gohr        $this->assertArrayHasKey('Bad',$headers);
66d1612d99SAndreas Gohr        $this->assertEquals("Thös ne\needs\x00serious cleaning\$§%.",$headers['Bad']);
67cc92aca7SAndreas Gohr        $this->assertArrayHasKey('Weird+foo.-_@bar',$headers);
68cc92aca7SAndreas Gohr
69cc92aca7SAndreas Gohr        // unset a header again
70cc92aca7SAndreas Gohr        $mail->setHeader('test-header','');
71cc92aca7SAndreas Gohr        $headers = $mail->prop('headers');
72cc92aca7SAndreas Gohr        $this->assertArrayNotHasKey('Test-Header',$headers);
73cc92aca7SAndreas Gohr    }
74cc92aca7SAndreas Gohr
75b6c97c70SAndreas Gohr    function test_addresses(){
76*1d7c1f1bSYurii K        if (isWindows()) {
77*1d7c1f1bSYurii K            $this->markTestSkipped();
78*1d7c1f1bSYurii K        }
79*1d7c1f1bSYurii K
80b6c97c70SAndreas Gohr        $mail = new TestMailer();
81b6c97c70SAndreas Gohr
82b6c97c70SAndreas Gohr        $mail->to('andi@splitbrain.org');
83b6c97c70SAndreas Gohr        $mail->cleanHeaders();
84b6c97c70SAndreas Gohr        $headers = $mail->prop('headers');
85b6c97c70SAndreas Gohr        $this->assertEquals('andi@splitbrain.org', $headers['To']);
86b6c97c70SAndreas Gohr
87b6c97c70SAndreas Gohr        $mail->to('<andi@splitbrain.org>');
88b6c97c70SAndreas Gohr        $mail->cleanHeaders();
89b6c97c70SAndreas Gohr        $headers = $mail->prop('headers');
90b6c97c70SAndreas Gohr        $this->assertEquals('andi@splitbrain.org', $headers['To']);
91b6c97c70SAndreas Gohr
92b6c97c70SAndreas Gohr        $mail->to('Andreas Gohr <andi@splitbrain.org>');
93b6c97c70SAndreas Gohr        $mail->cleanHeaders();
94b6c97c70SAndreas Gohr        $headers = $mail->prop('headers');
95b6c97c70SAndreas Gohr        $this->assertEquals('Andreas Gohr <andi@splitbrain.org>', $headers['To']);
96b6c97c70SAndreas Gohr
97b6c97c70SAndreas Gohr        $mail->to('Andreas Gohr <andi@splitbrain.org> , foo <foo@example.com>');
98b6c97c70SAndreas Gohr        $mail->cleanHeaders();
99b6c97c70SAndreas Gohr        $headers = $mail->prop('headers');
100b6c97c70SAndreas Gohr        $this->assertEquals('Andreas Gohr <andi@splitbrain.org>, foo <foo@example.com>', $headers['To']);
101b6c97c70SAndreas Gohr
102b6c97c70SAndreas Gohr        $mail->to('Möp <moep@example.com> , foo <foo@example.com>');
103b6c97c70SAndreas Gohr        $mail->cleanHeaders();
104b6c97c70SAndreas Gohr        $headers = $mail->prop('headers');
105b6c97c70SAndreas Gohr        $this->assertEquals('=?UTF-8?B?TcO2cA==?= <moep@example.com>, foo <foo@example.com>', $headers['To']);
106b6c97c70SAndreas Gohr
107b6c97c70SAndreas Gohr        $mail->to(array('Möp <moep@example.com> ',' foo <foo@example.com>'));
108b6c97c70SAndreas Gohr        $mail->cleanHeaders();
109b6c97c70SAndreas Gohr        $headers = $mail->prop('headers');
110b6c97c70SAndreas Gohr        $this->assertEquals('=?UTF-8?B?TcO2cA==?= <moep@example.com>, foo <foo@example.com>', $headers['To']);
111b6c97c70SAndreas Gohr
112b6c97c70SAndreas Gohr        $mail->to(array('Beet, L van <lvb@example.com>',' foo <foo@example.com>'));
113b6c97c70SAndreas Gohr        $mail->cleanHeaders();
114b6c97c70SAndreas Gohr        $headers = $mail->prop('headers');
115b6c97c70SAndreas Gohr        $this->assertEquals('=?UTF-8?B?QmVldCwgTCB2YW4=?= <lvb@example.com>, foo <foo@example.com>', $headers['To']);
116b6c97c70SAndreas Gohr
117b6c97c70SAndreas Gohr
118b6c97c70SAndreas Gohr    }
119b6c97c70SAndreas Gohr
120cc92aca7SAndreas Gohr    function test_simplemail(){
121cc92aca7SAndreas Gohr        global $conf;
122cc92aca7SAndreas Gohr        $conf['htmlmail'] = 0;
1239ea45836SChristopher Smith
1249ea45836SChristopher Smith        $mailbody = 'A test mail in ASCII';
125cc92aca7SAndreas Gohr        $mail = new TestMailer();
126cc92aca7SAndreas Gohr        $mail->to('test@example.com');
1279ea45836SChristopher Smith        $mail->setBody($mailbody);
128cc92aca7SAndreas Gohr
129cc92aca7SAndreas Gohr        $dump = $mail->dump();
1309ea45836SChristopher Smith
1319ea45836SChristopher Smith        // construct the expected mail body text - include the expected dokuwiki signature
1329ea45836SChristopher Smith        $replacements = $mail->prop('replacements');
1339ea45836SChristopher Smith        $expected_mail_body = chunk_split(base64_encode($mailbody.$replacements['text']['EMAILSIGNATURE']),72,MAILHEADER_EOL);
1349ea45836SChristopher Smith
135cc92aca7SAndreas Gohr        $this->assertNotRegexp('/Content-Type: multipart/',$dump);
136cc92aca7SAndreas Gohr        $this->assertRegexp('#Content-Type: text/plain; charset=UTF-8#',$dump);
1379ea45836SChristopher Smith        $this->assertRegexp('/'.preg_quote($expected_mail_body,'/').'/',$dump);
138cc92aca7SAndreas Gohr
139cc92aca7SAndreas Gohr        $conf['htmlmail'] = 1;
140cc92aca7SAndreas Gohr    }
141cc92aca7SAndreas Gohr
142cc92aca7SAndreas Gohr    function test_replacements(){
143cc92aca7SAndreas Gohr        $mail = new TestMailer();
144cc92aca7SAndreas Gohr
1459e01e280SChristopher Smith        $replacements = array( '@DATE@','@BROWSER@','@IPADDRESS@','@HOSTNAME@','@EMAILSIGNATURE@',
146cc92aca7SAndreas Gohr                               '@TITLE@','@DOKUWIKIURL@','@USER@','@NAME@','@MAIL@');
147cc92aca7SAndreas Gohr        $mail->setBody('A test mail in with replacements '.join(' ',$replacements));
148cc92aca7SAndreas Gohr
149cc92aca7SAndreas Gohr        $text = $mail->prop('text');
150cc92aca7SAndreas Gohr        $html = $mail->prop('html');
151cc92aca7SAndreas Gohr
152cc92aca7SAndreas Gohr        foreach($replacements as $repl){
153cc92aca7SAndreas Gohr            $this->assertNotRegexp("/$repl/",$text,"$repl replacement still in text");
154cc92aca7SAndreas Gohr            $this->assertNotRegexp("/$repl/",$html,"$repl replacement still in html");
155cc92aca7SAndreas Gohr        }
156cc92aca7SAndreas Gohr    }
157cc92aca7SAndreas Gohr
15891effd8dSDominik Eckelmann    /**
15991effd8dSDominik Eckelmann     * @see https://forum.dokuwiki.org/post/35822
16091effd8dSDominik Eckelmann     */
1611f61f312SDominik Eckelmann    function test_emptyBCCorCC() {
1621f61f312SDominik Eckelmann        $mail = new TestMailer();
1631f61f312SDominik Eckelmann        $headers = &$mail->propRef('headers');
1641f61f312SDominik Eckelmann        $headers['Bcc'] = '';
1651f61f312SDominik Eckelmann        $headers['Cc'] = '';
1661f61f312SDominik Eckelmann        $header = $mail->prepareHeaders();
1671f61f312SDominik Eckelmann        $this->assertEquals(0, preg_match('/(^|\n)Bcc: (\n|$)/', $header), 'Bcc found in headers.');
1686be717dbSMichael Hamann        $this->assertEquals(0, preg_match('/(^|\n)Cc: (\n|$)/', $header), 'Cc found in headers.');
1696be717dbSMichael Hamann    }
1706be717dbSMichael Hamann
1716be717dbSMichael Hamann    function test_nullTOorCCorBCC() {
1726be717dbSMichael Hamann        $mail = new TestMailer();
1736be717dbSMichael Hamann        $headers = &$mail->propRef('headers');
1746be717dbSMichael Hamann        $headers['Bcc'] = NULL;
1756be717dbSMichael Hamann        $headers['Cc'] = NULL;
1766be717dbSMichael Hamann        $headers['To'] = NULL;
1776be717dbSMichael Hamann        $header = $mail->prepareHeaders();
1786be717dbSMichael Hamann        $this->assertEquals(0, preg_match('/(^|\n)Bcc: (\n|$)/', $header), 'Bcc found in headers.');
1796be717dbSMichael Hamann        $this->assertEquals(0, preg_match('/(^|\n)Cc: (\n|$)/', $header), 'Cc found in headers.');
1806be717dbSMichael Hamann        $this->assertEquals(0, preg_match('/(^|\n)To: (\n|$)/', $header), 'To found in headers.');
1811f61f312SDominik Eckelmann    }
1820ee5ed1eSAndreas Gohr
1830ee5ed1eSAndreas Gohr    /**
1840ee5ed1eSAndreas Gohr     * @group internet
1850ee5ed1eSAndreas Gohr     */
1860ee5ed1eSAndreas Gohr    function test_lint(){
1870ee5ed1eSAndreas Gohr        // prepare a simple multipart message
1880ee5ed1eSAndreas Gohr        $mail = new TestMailer();
1890ee5ed1eSAndreas Gohr        $mail->to(array('Möp <moep@example.com> ',' foo <foo@example.com>'));
190d6e04b60SAndreas Gohr        $mail->from('Me <test@example.com>');
1910ee5ed1eSAndreas Gohr        $mail->subject('This is a töst');
1920ee5ed1eSAndreas Gohr        $mail->setBody('Hello Wörld,
1930ee5ed1eSAndreas Gohr
1940ee5ed1eSAndreas Gohr        please don\'t burn, okay?
1950ee5ed1eSAndreas Gohr        ');
196ec82d005SAndreas Gohr        $mail->attachContent('some test data', 'text/plain', 'a text.txt');
1970ee5ed1eSAndreas Gohr        $msg = $mail->dump();
1980ee5ed1eSAndreas Gohr        $msglines = explode("\n", $msg);
1990ee5ed1eSAndreas Gohr
200d6e04b60SAndreas Gohr        //echo $msg;
201d6e04b60SAndreas Gohr
2020ee5ed1eSAndreas Gohr        // ask message lint if it is okay
2030ee5ed1eSAndreas Gohr        $html = new HTTPClient();
2047468fb90SAndreas Gohr        $results = $html->post('https://tools.ietf.org/tools/msglint/msglint', array('msg'=>$msg));
20595e6ded1SAndreas Gohr        if($results === false) {
20695e6ded1SAndreas Gohr            $this->markTestSkipped('no response from validator');
20795e6ded1SAndreas Gohr            return;
20895e6ded1SAndreas Gohr        }
2090ee5ed1eSAndreas Gohr
2100ee5ed1eSAndreas Gohr        // parse the result lines
2110ee5ed1eSAndreas Gohr        $lines = explode("\n", $results);
2120ee5ed1eSAndreas Gohr        $rows  = count($lines);
2130ee5ed1eSAndreas Gohr        $i=0;
2140ee5ed1eSAndreas Gohr        while(trim($lines[$i]) != '-----------' && $i<$rows) $i++; //skip preamble
2150ee5ed1eSAndreas Gohr        for($i=$i+1; $i<$rows; $i++){
2160ee5ed1eSAndreas Gohr            $line = trim($lines[$i]);
2170ee5ed1eSAndreas Gohr            if($line == '-----------') break; //skip appendix
2180ee5ed1eSAndreas Gohr
2190ee5ed1eSAndreas Gohr            // get possible continuation of the line
2200ee5ed1eSAndreas Gohr            while($lines[$i+1][0] == ' '){
2210ee5ed1eSAndreas Gohr                $line .= ' '.trim($lines[$i+1]);
2220ee5ed1eSAndreas Gohr                $i++;
2230ee5ed1eSAndreas Gohr            }
2240ee5ed1eSAndreas Gohr
2250ee5ed1eSAndreas Gohr            // check the line for errors
226ec82d005SAndreas Gohr            if(substr($line,0,5) == 'ERROR' || substr($line,0,7) == 'WARNING'){
227d6e04b60SAndreas Gohr                // ignore some errors
228d6e04b60SAndreas Gohr                if(strpos($line, "missing mandatory header 'return-path'")) continue; #set by MDA
229acb389a8SAndreas Gohr                if(strpos($line, "bare newline in text body decoded")) continue; #we don't send mail bodies as CRLF, yet
230acb389a8SAndreas Gohr                if(strpos($line, "last decoded line too long")) continue; #we don't send mail bodies as CRLF, yet
231d6e04b60SAndreas Gohr
2320ee5ed1eSAndreas Gohr                // get the context in which the error occured
2330ee5ed1eSAndreas Gohr                $errorin = '';
2340ee5ed1eSAndreas Gohr                if(preg_match('/line (\d+)$/', $line, $m)){
2350ee5ed1eSAndreas Gohr                    $errorin .= "\n".$msglines[$m[1] - 1];
2360ee5ed1eSAndreas Gohr                }
2370ee5ed1eSAndreas Gohr                if(preg_match('/lines (\d+)-(\d+)$/', $line, $m)){
2380ee5ed1eSAndreas Gohr                    for($x=$m[1]-1; $x<$m[2]; $x++){
2390ee5ed1eSAndreas Gohr                        $errorin .= "\n".$msglines[$x];
2400ee5ed1eSAndreas Gohr                    }
2410ee5ed1eSAndreas Gohr                }
2420ee5ed1eSAndreas Gohr
2430ee5ed1eSAndreas Gohr                // raise the error
2440ee5ed1eSAndreas Gohr                throw new Exception($line.$errorin);
2450ee5ed1eSAndreas Gohr            }
2460ee5ed1eSAndreas Gohr        }
2470ee5ed1eSAndreas Gohr
2481bff2abaSAndreas Gohr        $this->assertTrue(true); // avoid being marked as risky for having no assertion
2490ee5ed1eSAndreas Gohr    }
250774514c9SGerrit Uitslag
251774514c9SGerrit Uitslag    function test_simplemailsignature() {
252774514c9SGerrit Uitslag        global $conf;
253774514c9SGerrit Uitslag        $conf['htmlmail'] = 0;
254774514c9SGerrit Uitslag
255774514c9SGerrit Uitslag        $mailbody = 'A test mail in ASCII';
256774514c9SGerrit Uitslag        $signature = "\n-- \n" . 'This mail was generated by DokuWiki at' . "\n" . DOKU_URL . "\n";
257774514c9SGerrit Uitslag        $mail = new TestMailer();
258774514c9SGerrit Uitslag        $mail->to('test@example.com');
259774514c9SGerrit Uitslag        $mail->setBody($mailbody);
260774514c9SGerrit Uitslag
261774514c9SGerrit Uitslag        $dump = $mail->dump();
262774514c9SGerrit Uitslag
263774514c9SGerrit Uitslag        // construct the expected mail body text - include the expected dokuwiki signature
264774514c9SGerrit Uitslag        $expected_mail_body = chunk_split(base64_encode($mailbody . $signature), 72, MAILHEADER_EOL);
265774514c9SGerrit Uitslag        $this->assertRegexp('/' . preg_quote($expected_mail_body, '/') . '/', $dump);
266774514c9SGerrit Uitslag
267774514c9SGerrit Uitslag        $conf['htmlmail'] = 1;
268774514c9SGerrit Uitslag    }
269774514c9SGerrit Uitslag
270774514c9SGerrit Uitslag    function test_htmlmailsignature() {
271774514c9SGerrit Uitslag        $mailbody_text = 'A test mail in ASCII :)';
272774514c9SGerrit Uitslag        $mailbody_html = 'A test mail in <strong>html</strong>';
273774514c9SGerrit Uitslag        $htmlmsg_expected = '<html>
274774514c9SGerrit Uitslag<head>
275774514c9SGerrit Uitslag    <title>My Test Wiki</title>
276774514c9SGerrit Uitslag    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
277774514c9SGerrit Uitslag</head>
278774514c9SGerrit Uitslag<body>
279774514c9SGerrit Uitslag
280774514c9SGerrit UitslagA test mail in <strong>html</strong>
281774514c9SGerrit Uitslag
282774514c9SGerrit Uitslag<br /><hr />
283f3cd98a0SGerrit Uitslag<small>This mail was generated by DokuWiki at<br /><a href="' . DOKU_URL . '">' . DOKU_URL . '</a></small>
284774514c9SGerrit Uitslag</body>
285774514c9SGerrit Uitslag</html>
286774514c9SGerrit Uitslag';
287774514c9SGerrit Uitslag
288774514c9SGerrit Uitslag        $mail = new TestMailer();
289774514c9SGerrit Uitslag        $mail->to('test@example.com');
290774514c9SGerrit Uitslag        $mail->setBody($mailbody_text, null, null, $mailbody_html);
291774514c9SGerrit Uitslag
292774514c9SGerrit Uitslag        $dump = $mail->dump();
293774514c9SGerrit Uitslag
294774514c9SGerrit Uitslag        // construct the expected mail body text - include the expected dokuwiki signature
295774514c9SGerrit Uitslag        $expected_mail_body = chunk_split(base64_encode($htmlmsg_expected), 72, MAILHEADER_EOL);
296774514c9SGerrit Uitslag
297774514c9SGerrit Uitslag        $this->assertRegexp('/Content-Type: multipart/', $dump);
298774514c9SGerrit Uitslag        $this->assertRegexp('#Content-Type: text/plain; charset=UTF-8#', $dump);
299774514c9SGerrit Uitslag        $this->assertRegexp('/' . preg_quote($expected_mail_body, '/') . '/', $dump);
300774514c9SGerrit Uitslag
301774514c9SGerrit Uitslag    }
302774514c9SGerrit Uitslag
303774514c9SGerrit Uitslag    function test_htmlmailsignaturecustom() {
304774514c9SGerrit Uitslag        global $lang;
305774514c9SGerrit Uitslag        $lang['email_signature_html'] = 'Official message from your DokuWiki @DOKUWIKIURL@<br />Created by wonderful mail class <a href="https://www.dokuwiki.org/devel:mail">https://www.dokuwiki.org/devel:mail</a>';
306774514c9SGerrit Uitslag
307774514c9SGerrit Uitslag        $mailbody_text = 'A test mail in ASCII :)';
308774514c9SGerrit Uitslag        $mailbody_html = 'A test mail in <strong>html</strong>';
309774514c9SGerrit Uitslag        $htmlmsg_expected = '<html>
310774514c9SGerrit Uitslag<head>
311774514c9SGerrit Uitslag    <title>My Test Wiki</title>
312774514c9SGerrit Uitslag    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
313774514c9SGerrit Uitslag</head>
314774514c9SGerrit Uitslag<body>
315774514c9SGerrit Uitslag
316774514c9SGerrit UitslagA test mail in <strong>html</strong>
317774514c9SGerrit Uitslag
318774514c9SGerrit Uitslag<br /><hr />
319f3cd98a0SGerrit Uitslag<small>Official message from your DokuWiki <a href="' . DOKU_URL . '">' . DOKU_URL . '</a><br />Created by wonderful mail class <a href="https://www.dokuwiki.org/devel:mail">https://www.dokuwiki.org/devel:mail</a></small>
320774514c9SGerrit Uitslag</body>
321774514c9SGerrit Uitslag</html>
322774514c9SGerrit Uitslag';
323774514c9SGerrit Uitslag
324774514c9SGerrit Uitslag        $mail = new TestMailer();
325774514c9SGerrit Uitslag        $mail->to('test@example.com');
326774514c9SGerrit Uitslag        $mail->setBody($mailbody_text, null, null, $mailbody_html);
327774514c9SGerrit Uitslag
328774514c9SGerrit Uitslag        $dump = $mail->dump();
329774514c9SGerrit Uitslag
330774514c9SGerrit Uitslag        // construct the expected mail body text - include the expected dokuwiki signature
331774514c9SGerrit Uitslag        $replacements = $mail->prop('replacements');
332774514c9SGerrit Uitslag        $expected_mail_body = chunk_split(base64_encode($htmlmsg_expected), 72, MAILHEADER_EOL);
333774514c9SGerrit Uitslag
334774514c9SGerrit Uitslag        $this->assertRegexp('/' . preg_quote($expected_mail_body, '/') . '/', $dump);
335774514c9SGerrit Uitslag
336774514c9SGerrit Uitslag    }
337cc92aca7SAndreas Gohr}
338cc92aca7SAndreas Gohr//Setup VIM: ex: et ts=4 :
339