From 0a4e0921d3c4e4e1e485f43dc05bf0447fbc846a Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Tue, 31 Mar 2015 10:07:51 -0400 Subject: [PATCH] Plugin API: Added message_ready hook - the last chance to modify Mail_Mime object before saving or sending the message --- CHANGELOG | 1 + program/steps/mail/sendmail.inc | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d14566d..41cd629 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ - Password plugin: Added 'kpasswd' driver by Peter Allgeyer - Add initdb.sh to create database from initial.sql script with prefix support (#1490188) - Plugin API: Added message_part_body hook +- Plugin API: Added message_ready hook - Plugin API: Add special onload() method to execute plugin actions before startup (session and GUI initialization) - Fix handling of %-encoded entities in mailto: URLs (#1490346) - Fix zipped messages downloads after selecting all messages in a folder (#1490339) diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index 5326d64..b3034f5 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -113,6 +113,12 @@ $from = null; } +// check 'From' address (identity may be incomplete) +if (!$savedraft && !$saveonly && empty($from)) { + $OUTPUT->show_message('nofromaddress', 'error'); + $OUTPUT->send('iframe'); +} + if (!$from_string && $from) { $from_string = $from; } @@ -508,14 +514,12 @@ // pass headers to message object $MAIL_MIME->headers($headers); +// This hook allows to modify the message before send or save action +$plugin = $RCMAIL->plugins->exec_hook('message_ready', array('message' => $MAIL_MIME)); +$MAIL_MIME = $plugin['message']; + // Begin SMTP Delivery Block if (!$savedraft && !$saveonly) { - // check 'From' address (identity may be incomplete) - if (empty($from)) { - $OUTPUT->show_message('nofromaddress', 'error'); - $OUTPUT->send('iframe'); - } - // Handle Delivery Status Notification request $smtp_opts['dsn'] = $dsn_enabled; -- Gitblit v1.9.1