mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-09-01 10:44:13 +08:00
Display BCC field in sent mail.
This commit is contained in:
parent
4a153a59c1
commit
f7106f375c
5 changed files with 114 additions and 17 deletions
|
@ -19,6 +19,11 @@ class Binary
|
|||
*/
|
||||
private static $aStreams = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $aRememberStreams = array();
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
|
@ -148,6 +153,35 @@ class Binary
|
|||
return \MailSo\Base\Utils::ConvertEncoding($sEncodedString, $sFromEncoding, $sToEncoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource $rStream
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function IsStreamRemembed($rStream)
|
||||
{
|
||||
foreach (self::$aRememberStreams as $rRem)
|
||||
{
|
||||
if ($rStream === $rRem)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource $rStream
|
||||
*/
|
||||
public static function RememberStream($rStream)
|
||||
{
|
||||
if (!self::IsStreamRemembed($rStream))
|
||||
{
|
||||
self::$aRememberStreams[] = $rStream;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource $rStream
|
||||
* @param string $sUtilsDecodeOrEncodeFunctionName = null
|
||||
|
|
|
@ -146,6 +146,22 @@ class Message
|
|||
return $oResult->Unique();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\EmailCollection|null
|
||||
*/
|
||||
public function GetBcc()
|
||||
{
|
||||
$oResult = null;
|
||||
|
||||
if (isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::BCC]) &&
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::BCC] instanceof \MailSo\Mime\EmailCollection)
|
||||
{
|
||||
$oResult = $this->aHeadersValue[\MailSo\Mime\Enumerations\Header::BCC];
|
||||
}
|
||||
|
||||
return $oResult ? $oResult->Unique() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
|
@ -552,10 +568,15 @@ class Message
|
|||
|
||||
if (is_resource($oAttachmentPart->Body))
|
||||
{
|
||||
$oAttachmentPart->Body =
|
||||
\MailSo\Base\StreamWrappers\Binary::CreateStream($oAttachmentPart->Body,
|
||||
\MailSo\Base\StreamWrappers\Binary::GetInlineDecodeOrEncodeFunctionName(
|
||||
\MailSo\Base\Enumerations\Encoding::BASE64, false));
|
||||
if (!\MailSo\Base\StreamWrappers\Binary::IsStreamRemembed($oAttachmentPart->Body))
|
||||
{
|
||||
$oAttachmentPart->Body =
|
||||
\MailSo\Base\StreamWrappers\Binary::CreateStream($oAttachmentPart->Body,
|
||||
\MailSo\Base\StreamWrappers\Binary::GetInlineDecodeOrEncodeFunctionName(
|
||||
\MailSo\Base\Enumerations\Encoding::BASE64, false));
|
||||
|
||||
\MailSo\Base\StreamWrappers\Binary::RememberStream($oAttachmentPart->Body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -618,10 +639,15 @@ class Message
|
|||
|
||||
if (is_resource($oAlternativePart->Body))
|
||||
{
|
||||
$oAlternativePart->Body =
|
||||
\MailSo\Base\StreamWrappers\Binary::CreateStream($oAlternativePart->Body,
|
||||
\MailSo\Base\StreamWrappers\Binary::GetInlineDecodeOrEncodeFunctionName(
|
||||
$aAlternativeData[2], false));
|
||||
if (!\MailSo\Base\StreamWrappers\Binary::IsStreamRemembed($oAlternativePart->Body))
|
||||
{
|
||||
$oAlternativePart->Body =
|
||||
\MailSo\Base\StreamWrappers\Binary::CreateStream($oAlternativePart->Body,
|
||||
\MailSo\Base\StreamWrappers\Binary::GetInlineDecodeOrEncodeFunctionName(
|
||||
$aAlternativeData[2], false));
|
||||
|
||||
\MailSo\Base\StreamWrappers\Binary::RememberStream($oAlternativePart->Body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -579,11 +579,28 @@ class Part
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resorce
|
||||
*/
|
||||
public function Rewind()
|
||||
{
|
||||
if ($this->Body && \is_resource($this->Body))
|
||||
{
|
||||
$aMeta = \stream_get_meta_data($this->Body);
|
||||
if (isset($aMeta['seekable']) && $aMeta['seekable'])
|
||||
{
|
||||
\rewind($this->Body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resorce
|
||||
*/
|
||||
public function ToStream()
|
||||
{
|
||||
$this->Rewind();
|
||||
|
||||
$aSubStreams = array(
|
||||
|
||||
$this->Headers->ToEncodedString().
|
||||
|
|
|
@ -140,7 +140,7 @@ class SmtpClient extends \MailSo\Net\NetClient
|
|||
/**
|
||||
* @param string $sServerName
|
||||
* @param int $iPort = 25
|
||||
* @param string $sEhloHost = '127.0.0.1'
|
||||
* @param string $sEhloHost = '[127.0.0.1]'
|
||||
* @param int $iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT
|
||||
*
|
||||
* @return \MailSo\Smtp\SmtpClient
|
||||
|
@ -149,7 +149,7 @@ class SmtpClient extends \MailSo\Net\NetClient
|
|||
* @throws \MailSo\Net\Exceptions\Exception
|
||||
* @throws \MailSo\Smtp\Exceptions\ResponseException
|
||||
*/
|
||||
public function Connect($sServerName, $iPort = 25, $sEhloHost = '127.0.0.1',
|
||||
public function Connect($sServerName, $iPort = 25, $sEhloHost = '[127.0.0.1]',
|
||||
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::AUTO_DETECT)
|
||||
{
|
||||
$this->iRequestTime = microtime(true);
|
||||
|
|
|
@ -3892,15 +3892,35 @@ class Actions
|
|||
{
|
||||
try
|
||||
{
|
||||
if (\is_resource($rMessageStream))
|
||||
if (!$oMessage->GetBcc())
|
||||
{
|
||||
@\rewind($rMessageStream);
|
||||
}
|
||||
if (\is_resource($rMessageStream))
|
||||
{
|
||||
\rewind($rMessageStream);
|
||||
}
|
||||
|
||||
$this->MailClient()->MessageAppendStream(
|
||||
$rMessageStream, $iMessageStreamSize, $sSentFolder, array(
|
||||
\MailSo\Imap\Enumerations\MessageFlag::SEEN
|
||||
));
|
||||
$this->MailClient()->MessageAppendStream(
|
||||
$rMessageStream, $iMessageStreamSize, $sSentFolder, array(
|
||||
\MailSo\Imap\Enumerations\MessageFlag::SEEN
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
$rAppendMessageStream = \MailSo\Base\ResourceRegistry::CreateMemoryResource();
|
||||
|
||||
$iAppendMessageStreamSize = \MailSo\Base\Utils::MultipleStreamWriter(
|
||||
$oMessage->ToStream(false), array($rAppendMessageStream), 8192, true, true, true);
|
||||
|
||||
$this->MailClient()->MessageAppendStream(
|
||||
$rAppendMessageStream, $iAppendMessageStreamSize, $sSentFolder, array(
|
||||
\MailSo\Imap\Enumerations\MessageFlag::SEEN
|
||||
));
|
||||
|
||||
if (is_resource($rAppendMessageStream))
|
||||
{
|
||||
@fclose($rAppendMessageStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue