/* This function is used when not sending or adding attachments */
function newMail ($imapConnection, $mailbox='', $passed_id='', $passed_ent_id='', $action='', $session='') {
global $editor_size, $default_use_priority,
- $use_signature, $composesession;
-
- $send_to = $send_to_cc = $send_to_bcc = $subject = $mailprio = $body = '';
+ $use_signature, $composesession, $data_dir, $username;
+ $send_to = $send_to_cc = $send_to_bcc = $subject = $body = $identity = '';
+ $mailprio = 3;
if ($passed_id) {
sqimap_mailbox_select($imapConnection, $mailbox);
$message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
$mailprio = '';
}
ClearAttachments($session);
+
+ $identity = '';
+ $idents = getPref($data_dir, $username, 'identities');
+ $from_o = $message->header->from;
+ if (is_object($from_o)) {
+ $orig_from = $from_o->getAddress();
+ } else {
+ $orig_from = '';
+ }
+ if (!empty($idents) && $idents > 1) {
+ for ($i = 1; $i < $idents; $i++) {
+ $enc_from_name = '"'.
+ getPref($data_dir,
+ $username,
+ 'full_name' . $i) .
+ '" <' . getPref($data_dir, $username,
+ 'email_address' . $i) . '>';
+ if ($enc_from_name == $orig_from) {
+ $identity = $i;
+ break;
+ }
+ }
+ }
+
switch ($action) {
case ('draft'):
$use_signature = FALSE;
$send_to_bcc = $orig_header->getAddr_s('bcc');
$subject = $orig_header->subject;
$mailprio = $orig_header->priority;
+ $orig_from = '';
getAttachments($message, $session, $passed_id, $entities, $imapConnection);
sqUnWordWrap($body);
break;
case ('forward'):
$send_to = '';
- $orig_from = $orig_header->from->getAddress();
+// $orig_from = $orig_header->from->getAddress();
$subject = $orig_header->subject;
if ((substr(strtolower($subject), 0, 4) != 'fwd:') &&
(substr(strtolower($subject), 0, 5) != '[fwd:') &&
} else {
$send_to = $orig_header->from->getAddress();
}
- $orig_from = $orig_header->from->getAddress();
+// $orig_from = $orig_header->from->getAddress();
$subject = $orig_header->subject;
$subject = str_replace('"', "'", $subject);
$subject = trim($subject);
'send_to_bcc' => $send_to_bcc,
'subject' => $subject,
'mailprio' => $mailprio,
- 'body' => $body
+ 'body' => $body,
+ 'identity' => $identity
);
return ($ret);
$subject = $values['subject'];
$mailprio = $values['mailprio'];
$body = $values['body'];
+ $identity = $values['identity'];
}
if ($use_javascript_addr_book) {