X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=plugins%2Flistcommands%2Ffunctions.php;h=fce3487e4c6f10c68bbc1c228e0a0d69c527737f;hp=b1e4a227f70b1c259f44e721d2747ebe6b7ee5da;hb=c4faef335b2362c81b8ebf026d4066c12d70536c;hpb=d4e46166df04792c6b939356ea5dfda8e47bba7b diff --git a/plugins/listcommands/functions.php b/plugins/listcommands/functions.php index b1e4a227..fce3487e 100644 --- a/plugins/listcommands/functions.php +++ b/plugins/listcommands/functions.php @@ -8,7 +8,7 @@ * this plugin displays a menu which gives the user a choice of mailinglist * commands such as (un)subscribe, help and list archives. * - * @copyright © 1999-2009 The SquirrelMail Project Team + * @copyright 1999-2020 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package plugins @@ -84,18 +84,48 @@ function plugin_listcommands_menu_do() { /* proto = {mailto,href} */ $aActions = array_keys($actions); + // note that we only use the first cmd/action, ignore the rest $proto = array_shift($aActions); $act = array_shift($actions); if ($proto == 'mailto') { + $identity = ''; + if (($cmd == 'post') || ($cmd == 'owner')) { $url = 'src/compose.php?'. (isset($startMessage)?'startMessage='.$startMessage.'&':''); } else { $url = "plugins/listcommands/mailout.php?action=$cmd&"; + + // try to find which identity the mail should come from + include_once(SM_PATH . 'functions/identity.php'); + $idents = get_identities(); + // ripped from src/compose.php + $identities = array(); + if (count($idents) > 1) { + foreach($idents as $nr=>$data) { + $enc_from_name = '"'.$data['full_name'].'" <'. $data['email_address'].'>'; + $identities[] = $enc_from_name; + } + + $identity_match = $message->rfc822_header->findAddress($identities); + if ($identity_match !== FALSE) { + $identity = $identity_match; + } + } } - $url .= 'send_to=' . str_replace('?','&', $act); + + // if things like subject are given, peel them off and give + // them to src/compose.php as is (not encoded) + if (strpos($act, '?') > 0) { + list($act, $parameters) = explode('?', $act, 2); + $parameters = '&identity=' . $identity . '&' . $parameters; + } else { + $parameters = '&identity=' . $identity; + } + + $url .= 'send_to=' . urlencode($act) . $parameters; $links[$cmd] = makeComposeLink($url, $fieldsdescr[$cmd]);