mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
* Mail: when changing account on compose, we no longer fake the sender, but we use the outgoing Server settings of that account AND copy the sent message to that accounts sentfolder (if set and prefs suggest we should store a copy in the selected accounts sentfolder)
This commit is contained in:
parent
ab3ffca7f8
commit
8f30c7c25e
@ -257,7 +257,7 @@ class mail_compose
|
||||
//error_log(__METHOD__.__LINE__.' CurrentFolder:'.$activeFolderCache[$this->mail_bo->profileID]);
|
||||
$activeFolder = $activeFolderCache[$this->mail_bo->profileID];
|
||||
}
|
||||
|
||||
//error_log(__METHOD__.__LINE__.array2string($_content));
|
||||
if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID &&
|
||||
($_content['button']['send'] || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint'])
|
||||
)
|
||||
@ -2553,6 +2553,15 @@ class mail_compose
|
||||
#print "<pre>". $mail->getMessageBody() ."</pre><hr><br>";
|
||||
#exit;
|
||||
|
||||
// we use the authentication data of the choosen mailaccount
|
||||
if ($_formData['serverID']!=$_formData['mailaccount'])
|
||||
{
|
||||
$this->changeProfile($_formData['mailaccount']);
|
||||
}
|
||||
// sentFolder is account specific
|
||||
$sentFolder = $this->mail_bo->getSentFolder();
|
||||
if (!$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false;
|
||||
// we do not fake the sender (anymore), we use the account settings for server and authentication of the choosen account
|
||||
$ogServer = $this->mail_bo->ogServer;
|
||||
//_debug_array($ogServer);
|
||||
$mail->Host = $ogServer->host;
|
||||
@ -2566,6 +2575,11 @@ class mail_compose
|
||||
$mail->Username = $username;
|
||||
$mail->Password = $ogServer->password;
|
||||
}
|
||||
// we switch back from authentication data to the account we used to work on
|
||||
if ($_formData['serverID']!=$_formData['mailaccount'])
|
||||
{
|
||||
$this->changeProfile($_formData['serverID']);
|
||||
}
|
||||
|
||||
// check if there are folders to be used
|
||||
$folderToCheck = (array)$this->sessionData['folder'];
|
||||
@ -2577,12 +2591,11 @@ class mail_compose
|
||||
$folder[] = $f;
|
||||
}
|
||||
}
|
||||
$sentFolder = $this->mail_bo->getSentFolder();
|
||||
if(isset($sentFolder) && $sentFolder != 'none' &&
|
||||
if(isset($sentFolder) && $sentFolder && $sentFolder != 'none' &&
|
||||
$this->mailPreferences['sendOptions'] != 'send_only' &&
|
||||
$messageIsDraft == false)
|
||||
{
|
||||
if ($this->mail_bo->folderExists($sentFolder, true))
|
||||
if ($sentFolder)
|
||||
{
|
||||
$folder[] = $sentFolder;
|
||||
}
|
||||
@ -2675,6 +2688,8 @@ class mail_compose
|
||||
{
|
||||
foreach($folder as $folderName) {
|
||||
if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all
|
||||
// if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID
|
||||
if($mail_bo->isSentFolder($folderName) && $_formData['serverID']!=$_formData['mailaccount']) continue;
|
||||
if($mail_bo->isSentFolder($folderName)) {
|
||||
$flags = '\\Seen';
|
||||
} elseif($mail_bo->isDraftFolder($folderName)) {
|
||||
@ -2705,6 +2720,35 @@ class mail_compose
|
||||
error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName));
|
||||
}
|
||||
}
|
||||
// if we choose to send from a differing profile
|
||||
if ($_formData['serverID']!=$_formData['mailaccount'])
|
||||
{
|
||||
// we assume the intention is to see the sent mail in the sentfolder
|
||||
// of that account, that is, if there is one at all, and our options
|
||||
// suggest it
|
||||
if(isset($sentFolder) && $sentFolder != 'none' &&
|
||||
$this->mailPreferences['sendOptions'] != 'send_only')
|
||||
{
|
||||
$this->changeProfile($_formData['mailaccount']);
|
||||
$sentFolder = $this->mail_bo->getSentFolder();
|
||||
try
|
||||
{
|
||||
$flags = '\\Seen';
|
||||
//error_log(__METHOD__.__LINE__.array2string($folderName));
|
||||
$this->mail_bo->appendMessage($sentFolder,
|
||||
$sentMailHeader,
|
||||
$sentMailBody,
|
||||
$flags);
|
||||
}
|
||||
catch (egw_exception_wrong_userinput $e)
|
||||
{
|
||||
error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$this->sessionData['subject'],$folderName,$e->getMessage()));
|
||||
}
|
||||
|
||||
$this->changeProfile($_formData['serverID']);
|
||||
}
|
||||
}
|
||||
|
||||
//$mail_bo->closeConnection();
|
||||
}
|
||||
// handle previous drafted versions of that mail
|
||||
|
Loading…
Reference in New Issue
Block a user