Skip to content

Commit 1adc13f

Browse files
committed
issue-873 Fix mixed-format email output when mail type text mode is selected
1 parent e21c0bf commit 1adc13f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/Email/Email.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function put($path, $contents) {
6565
$ident = $this->FreePBX->Config->get("FREEPBX_SYSTEM_IDENT");
6666
$subject = isset($this->mailOptions['subject']) ? trim($this->mailOptions['subject']) :'';
6767
$body = isset($this->mailOptions['body']) ? trim($this->mailOptions['body']) :'';
68-
$emailType = isset($this->mailOptions['emailType']) ? trim($this->mailOptions['emailType']) :'';
68+
$emailType = isset($this->mailOptions['emailType']) ? strtolower(trim($this->mailOptions['emailType'])) :'';
6969
if ($body =='') {
7070
$body = !empty($this->config['body'])?$this->config['body']:sprintf(_("File from %s, Identifier: %s"),$brand,$ident);
7171
}
@@ -76,7 +76,14 @@ public function put($path, $contents) {
7676
$mail->subject($subject);
7777
$mail->from($from);
7878
$mail->to($to);
79-
$mail->set_mailtype("html");
79+
$mailType = ($emailType === 'text') ? 'text' : 'html';
80+
$mail->set_mailtype($mailType);
81+
if ($mailType === 'html') {
82+
$mail->message($body);
83+
} else {
84+
$mail->set_wordwrap(false);
85+
$mail->message(html_entity_decode($body, ENT_QUOTES));
86+
}
8087
$mail->message($body);
8188
$mail->attach($path);
8289
$ret = $mail->send();

0 commit comments

Comments
 (0)