Commit 4f278391 authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-1033 Implement send-as in Kopano->SendMail(). KOE and serverside send

as are supported.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 8fc5e696
...@@ -444,6 +444,36 @@ class BackendKopano implements IBackend, ISearchProvider { ...@@ -444,6 +444,36 @@ class BackendKopano implements IBackend, ISearchProvider {
Utils::PrintAsString((isset($sm->source->folderid) ? $sm->source->folderid : false)), Utils::PrintAsString((isset($sm->source->folderid) ? $sm->source->folderid : false)),
Utils::PrintAsString(($sm->saveinsent)), Utils::PrintAsString(isset($sm->replacemime)) )); Utils::PrintAsString(($sm->saveinsent)), Utils::PrintAsString(isset($sm->replacemime)) ));
// Send-As functionality - https://jira.z-hub.io/browse/ZP-908
$sendingAsSomeone = false;
if (defined('KOE_CAPABILITY_SENDAS') && KOE_CAPABILITY_SENDAS) {
$senderEmail = array();
// KOE: grep for the Sender header indicating we should send-as
// the 'X-Push-Sender-Name' header is not used
if (preg_match("/^X-Push-Sender:\s(.*?)$/im", $sm->mime, $senderEmail)) {
$sendAsEmail = trim($senderEmail[1]);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("SendMail(): Send-As '%s' requested by KOE", $sendAsEmail));
$sm->mime = preg_replace("/^From: .*?$/im", "From: ". $sendAsEmail, $sm->mime, 1);
$sendingAsSomeone = true;
}
// serverside Send-As - shared folder with DeviceManager::FLD_FLAGS_REPLYASUSER flag
elseif (isset($sm->source->folderid)) {
// get the owner of this folder - System is not allowed
$sharedUser = ZPush::GetAdditionalSyncFolderStore($sm->source->folderid);
if ($sharedUser != false && $sharedUser != 'SYSTEM') {
$folders = ZPush::GetAdditionalSyncFolders();
if (isset($folders[$sm->source->folderid]) && ($folders[$sm->source->folderid]->Flags & DeviceManager::FLD_FLAGS_REPLYASUSER)) {
$sendAs = $this->resolveRecipientGAL($sharedUser, 1);
if (isset($sendAs[0])) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("SendMail(): Server side Send-As activated for shared folder. Sending as '%s'.", $sendAs[0]->emailaddress));
$sm->mime = preg_replace("/^From: .*?$/im", "From: ". $sendAs[0]->emailaddress, $sm->mime, 1);
$sendingAsSomeone = true;
}
}
}
}
}
// by splitting the message in several lines we can easily grep later // by splitting the message in several lines we can easily grep later
foreach(preg_split("/((\r)?\n)/", $sm->mime) as $rfc822line) foreach(preg_split("/((\r)?\n)/", $sm->mime) as $rfc822line)
ZLog::Write(LOGLEVEL_WBXML, "RFC822: ". $rfc822line); ZLog::Write(LOGLEVEL_WBXML, "RFC822: ". $rfc822line);
...@@ -507,9 +537,12 @@ class BackendKopano implements IBackend, ISearchProvider { ...@@ -507,9 +537,12 @@ class BackendKopano implements IBackend, ISearchProvider {
// PR_SENT_REPRESENTING_EMAIL_ADDRESS properties and "broken" PR_SENT_REPRESENTING_ENTRYID // PR_SENT_REPRESENTING_EMAIL_ADDRESS properties and "broken" PR_SENT_REPRESENTING_ENTRYID
// which results in spooler not being able to send the message. // which results in spooler not being able to send the message.
// @see http://jira.zarafa.com/browse/ZP-85 // @see http://jira.zarafa.com/browse/ZP-85
// If using KOE send-as feature, we keep this properties because they actually are the send-as
if (!$sendingAsSomeone) {
mapi_deleteprops($mapimessage, mapi_deleteprops($mapimessage,
array( $sendMailProps["sentrepresentingname"], $sendMailProps["sentrepresentingemail"], $sendMailProps["representingentryid"], array( $sendMailProps["sentrepresentingname"], $sendMailProps["sentrepresentingemail"], $sendMailProps["representingentryid"],
$sendMailProps["sentrepresentingaddt"], $sendMailProps["sentrepresentinsrchk"])); $sendMailProps["sentrepresentingaddt"], $sendMailProps["sentrepresentinsrchk"]));
}
if(isset($sm->source->itemid) && $sm->source->itemid) { if(isset($sm->source->itemid) && $sm->source->itemid) {
// answering an email in a public/shared folder // answering an email in a public/shared folder
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment