| | |
| | | } |
| | | |
| | | $from_idx = null; |
| | | $default_identity = null; |
| | | $found_idx = null; |
| | | $default_identity = 0; // default identity is always first on the list |
| | | $return_path = $MESSAGE->headers->others['return-path']; |
| | | |
| | | // Select identity |
| | | foreach ($MESSAGE->identities as $idx => $ident) { |
| | | // save default identity ID |
| | | if ($ident['standard']) { |
| | | $default_identity = $idx; |
| | | } |
| | | |
| | | // use From header |
| | | if (in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT))) { |
| | | if ($MESSAGE->headers->from == $ident['ident']) { |
| | |
| | | } |
| | | // use replied message recipients |
| | | else if (($found = array_search($ident['email_ascii'], $a_recipients)) !== false) { |
| | | // match identity name, prefer default identity |
| | | if ($from_idx === null || ($a_names[$found] && $ident['name'] && $a_names[$found] == $ident['name'])) { |
| | | if ($found_idx === null) { |
| | | $found_idx = $idx; |
| | | } |
| | | // match identity name |
| | | if ($a_names[$found] && $ident['name'] && $a_names[$found] == $ident['name']) { |
| | | $from_idx = $idx; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // If matching by name+address doesn't found any amtches, get first found address (identity) |
| | | if ($from_idx === null) { |
| | | $from_idx = $found_idx; |
| | | } |
| | | |
| | | // Fallback using Return-Path |
| | |
| | | } |
| | | } |
| | | |
| | | // Still no ID, use default/first identity |
| | | if ($from_idx === null) { |
| | | $from_idx = $default_identity !== null ? $default_identity : key(reset($MESSAGE->identities)); |
| | | } |
| | | |
| | | $ident = $MESSAGE->identities[$from_idx]; |
| | | $ident = $MESSAGE->identities[$from_idx !== null ? $from_idx : $default_identity]; |
| | | $from_id = $ident['identity_id']; |
| | | |
| | | $MESSAGE->compose['from_email'] = $ident['email']; |
| | |
| | | else if (in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT))) { |
| | | // get drafted headers |
| | | if ($header=='to' && !empty($MESSAGE->headers->to)) |
| | | $fvalue = $MESSAGE->get_header('to'); |
| | | $fvalue = $MESSAGE->get_header('to', true); |
| | | else if ($header=='cc' && !empty($MESSAGE->headers->cc)) |
| | | $fvalue = $MESSAGE->get_header('cc'); |
| | | $fvalue = $MESSAGE->get_header('cc', true); |
| | | else if ($header=='bcc' && !empty($MESSAGE->headers->bcc)) |
| | | $fvalue = $MESSAGE->get_header('bcc'); |
| | | $fvalue = $MESSAGE->get_header('bcc', true); |
| | | else if ($header=='replyto' && !empty($MESSAGE->headers->others['mail-reply-to'])) |
| | | $fvalue = $MESSAGE->get_header('mail-reply-to'); |
| | | else if ($header=='replyto' && !empty($MESSAGE->headers->replyto)) |
| | |
| | | |
| | | if (!$bodyIsHtml) { |
| | | $body = preg_replace('/\r?\n/', "\n", $body); |
| | | $body = trim($body, "\n"); |
| | | |
| | | // soft-wrap and quote message text |
| | | $body = rcmail_wrap_and_quote(rtrim($body, "\n"), $LINE_LENGTH); |
| | | $body = rcmail_wrap_and_quote($body, $LINE_LENGTH); |
| | | |
| | | $prefix .= "\n"; |
| | | $suffix = ''; |
| | |
| | | $date = format_date($MESSAGE->headers->date, $RCMAIL->config->get('date_long')); |
| | | $charset = $RCMAIL->output->get_charset(); |
| | | |
| | | if (!$bodyIsHtml) |
| | | { |
| | | if (!$bodyIsHtml) { |
| | | $prefix = "\n\n\n-------- " . rcube_label('originalmessage') . " --------\n"; |
| | | $prefix .= rcube_label('subject') . ': ' . $MESSAGE->subject . "\n"; |
| | | $prefix .= rcube_label('date') . ': ' . $date . "\n"; |
| | |
| | | $prefix .= rcube_label('replyto') . ': ' . $MESSAGE->get_header('replyto') . "\n"; |
| | | |
| | | $prefix .= "\n"; |
| | | $body = trim($body, "\r\n"); |
| | | } |
| | | else |
| | | { |
| | | else { |
| | | // set is_safe flag (we need this for html body washing) |
| | | rcmail_check_safe($MESSAGE); |
| | | // clean up html tags |