I've got that plugin installed too. Here's some tests I carried out yesterday
in
lib/plugins/smtp/admin.php
I added some additional text to the outgoing test message to ensure I was testing the right part of the code :
#line ~36
$mail->subject('DokuWiki says hello!!');
$mail->setBody('Hi This is a test, really it is');
$ok = $mail->send();
I then looked up the Mailer class
grep -ri "class Mailer"
and edited the file
joe inc/Mailer.class.php
I found the sender method and added some echo's
public function send() {
$success = false;
echo "<hr>3 ".$this->text;
// prepare hook data
$data = array(
// pass the whole mail class to plugin
'mail' => $this,
// pass references for backward compatibility
'to' => &$this->headers['To'],
'cc' => &$this->headers['Cc'],
'bcc' => &$this->headers['Bcc'],
'from' => &$this->headers['From'],
'subject' => &$this->headers['Subject'],
'body' => &$this->text,
'params' => &$this->sendparam,
'headers' => '', // plugins shouldn't use this
// signal if we mailed successfully to AFTER event
'success' => &$success,
);
// do our thing if BEFORE hook approves
$evt = new Doku_Event('MAIL_MESSAGE_SEND', $data);
echo "<hr>4 Before Hook ".$this->text;
if($evt->advise_before(true)) {
echo "<hr>5 advise beofre = true";
// clean up before using the headers
$this->cleanHeaders();
// any recipients?
if(trim($this->headers['To']) === '' &&
trim($this->headers['Cc']) === '' &&
trim($this->headers['Bcc']) === ''
) return false;
// The To: header is special
if(array_key_exists('To', $this->headers)) {
$to = (string)$this->headers['To'];
unset($this->headers['To']);
} else {
$to = '';
}
// so is the subject
if(array_key_exists('Subject', $this->headers)) {
$subject = (string)$this->headers['Subject'];
unset($this->headers['Subject']);
} else {
$subject = '';
}
// make the body
echo "<hr>6 Make the body";
$body = $this->prepareBody();
if($body === false) return false;
// cook the headers
$headers = $this->prepareHeaders();
// add any headers set by legacy plugins
if(trim($data['headers'])) {
$headers .= MAILHEADER_EOL.trim($data['headers']);
}
// send the thing
echo "Sending";
if(is_null($this->sendparam)) {
echo "<hr>7 ".$body;
$myecho = "first";
$success = @mail($to, $subject, $body, $headers);
} else {
echo "<hr>8 ".$body;
$myecho = "second";
$success = @mail($to, $subject, $body, $headers, $this->sendparam);
}
}
echo "<hr>9 after actions :".$myecho.":";
// any AFTER actions?
$evt->advise_after();
return $success;
}
This is the output I get :
2Hi This is a test, really it is -- This mail was generated by DokuWiki at https://<domainname>/planning/
3 Hi This is a test, really it is -- This mail was generated by DokuWiki at https://<domainname>/planning/
4 Before Hook Hi This is a test, really it is -- This mail was generated by DokuWiki at https://<domainname>/planning/
9 after actions ::
So I can see that the message body text gets right through to the part that actually tries to send the message. However it never seems to get into the conditional block with the comment
//send the thing
as neither markers 7 or 8 are printed and the $myecho var is not set. The email is still sent though.
Looking in the emails that get sent (using gmail or outlook, I've tested sending to both) there is no body.
My SMTP plugin is configured to go to our local exchange server. I'm setting up another wiki on another VM with its own local smtp service to see if the body is being stripped by exchange...