forked from splitbrain/dokuwiki-plugin-smtp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
71 lines (58 loc) · 1.92 KB
/
admin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* Swiftmail Plugin
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <[email protected]>
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
class admin_plugin_smtp extends DokuWiki_Admin_Plugin {
/**
* return sort order for position in admin menu
*/
function getMenuSort() {
return 200;
}
/**
* handle user request
*/
function handle() {
global $INPUT;
global $conf;
if(!$INPUT->bool('send')) return;
// make sure debugging is on;
$conf['plugin']['smtp']['debug'] = 1;
// send a mail
$mail = new Mailer();
if($INPUT->str('to')) $mail->to($INPUT->str('to'));
if($INPUT->str('cc')) $mail->cc($INPUT->str('cc'));
if($INPUT->str('bcc')) $mail->bcc($INPUT->str('bcc'));
$mail->subject('DokuWiki says hello');
$mail->setBody("Hi @USER@\n\nThis is a test from @DOKUWIKIURL@");
$ok = $mail->send();
// check result
if($ok){
msg('Message was sent. SMTP seems to work.',1);
}else{
msg('Message wasn\'t sent. SMTP seems not to work properly.',-1);
}
}
/**
* Output HTML form
*/
function html() {
global $INPUT;
global $conf;
echo $this->locale_xhtml('intro');
if(!$conf['mailfrom']) msg($this->getLang('nofrom'),-1);
$form = new Doku_Form(array());
$form->startFieldset('Testmail');
$form->addHidden('send', 1);
$form->addElement(form_makeField('text', 'to', $INPUT->str('to'), 'To:', '', 'block'));
$form->addElement(form_makeField('text', 'cc', $INPUT->str('cc'), 'Cc:', '', 'block'));
$form->addElement(form_makeField('text', 'bcc', $INPUT->str('bcc'), 'Bcc:', '', 'block'));
$form->addElement(form_makeButton('submit', '', 'Send Email'));
$form->printForm();
}
}