continue mail implementation

This commit is contained in:
Dennis Eichhorn 2020-04-13 10:43:59 +02:00
parent 739c92c87f
commit 2c9d8fe6aa

View File

@ -444,6 +444,23 @@ class Mail
return true; return true;
} }
public function addStringAttachment() : bool
{
}
public function addEmbeddedImage() : bool
{
}
public function addStringEmbeddedImage() : bool
{
}
/** /**
* The email should be confirmed by the receivers * The email should be confirmed by the receivers
* *
@ -752,11 +769,24 @@ class Mail
if ($this->signKeyFile !== '') { if ($this->signKeyFile !== '') {
// @todo implement // @todo implement
$output .= '';
} }
return $output; return $output;
} }
public function createHtmlMsg() : void
{
}
private function htmlToText() : string
{
}
/** /**
* Normalize text * Normalize text
* *
@ -867,23 +897,22 @@ class Mail
foreach ($words as $word) { foreach ($words as $word) {
if ($quoted && \strlen($word) > $length) { if ($quoted && \strlen($word) > $length) {
if ($first) {
$spaces = $length - \strlen($buffer) - $crlfLength; $spaces = $length - \strlen($buffer) - $crlfLength;
if ($first) {
if ($spaces > 20) { if ($spaces > 20) {
$len = $spaces; $len = $spaces;
if ($isUTF8) { if ($isUTF8) {
$len = MbStringUtils::utf8CharBoundary($word, $len); $len = MbStringUtils::utf8CharBoundary($word, $len);
} elseif ('=' === \substr($word, $len - 1, 1)) { } elseif ($word[$len - 1] === '=') {
--$len; --$len;
} elseif ('=' === \substr($word, $len - 2, 1)) { } elseif ($word[$len - 2] === '=') {
$len -= 2; $len -= 2;
} }
$part = \substr($word, 0, $len); $part = \substr($word, 0, $len);
$word = \substr($word, $len); $word = \substr($word, $len);
$buffer .= ' ' . $part; $output .= $buffer . ' ' . $part . '=' . $this->endOfLine;
$output .= $buffer . '=' . $this->endOfLine;
} else { } else {
$output .= $buffer . $softEndOfLine; $output .= $buffer . $softEndOfLine;
} }
@ -900,9 +929,9 @@ class Mail
if ($isUTF8) { if ($isUTF8) {
$len = MbStringUtils::utf8CharBoundary($word, $len); $len = MbStringUtils::utf8CharBoundary($word, $len);
} elseif ('=' === \substr($word, $len - 1, 1)) { } elseif ($word[$len - 1] === '=') {
--$len; --$len;
} elseif ('=' === \substr($word, $len - 2, 1)) { } elseif ($word[$len - 2] === '=') {
$len -= 2; $len -= 2;
} }
@ -991,6 +1020,16 @@ class Mail
return $encoded; return $encoded;
} }
/**
* Attach all attachments
*
* @param string $disposition Disposition type
* @param string $boundary Boundary identifier
*
* @return string
*
* @since 1.0.0
*/
private function attachAll(string $disposition, string $boundary) : string private function attachAll(string $disposition, string $boundary) : string
{ {
$mime = []; $mime = [];
@ -1011,6 +1050,7 @@ class Mail
} }
$cid[$attach['id']] = true; $cid[$attach['id']] = true;
$mime[] = '--' . $boundary . $this->endOfLine; $mime[] = '--' . $boundary . $this->endOfLine;
$mime[] = !empty($attach['name']) $mime[] = !empty($attach['name'])
? 'Content-Type: ' . $attach['type'] . '; name="' . $this->encodeHeader(\trim(\str_replace(["\r", "\n"], '', $attach['name']))) . '"' . $this->endOfLine ? 'Content-Type: ' . $attach['type'] . '; name="' . $this->encodeHeader(\trim(\str_replace(["\r", "\n"], '', $attach['name']))) . '"' . $this->endOfLine
@ -1044,6 +1084,16 @@ class Mail
return \implode('', $mime); return \implode('', $mime);
} }
/**
* Encode header value
*
* @param string $value Value to encode
* @param int $context Value context
*
* @return string
*
* @since 1.0.0
*/
private function encodeHeader(string $value, int $context = HeaderContext::TEXT) : string private function encodeHeader(string $value, int $context = HeaderContext::TEXT) : string
{ {
$matches = 0; $matches = 0;
@ -1059,6 +1109,7 @@ class Mail
break; break;
case HeaderContext::COMMENT: case HeaderContext::COMMENT:
$matches = \preg_match_all('/[()"]/', $value, $matched); $matches = \preg_match_all('/[()"]/', $value, $matched);
/* fallthrough */
default: default:
$matches += \preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $value, $matched); $matches += \preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $value, $matched);
} }
@ -1088,6 +1139,16 @@ class Mail
return \trim($this->normalizeText($encoded)); return \trim($this->normalizeText($encoded));
} }
/**
* Encode a file
*
* @param string $path Path to a file
* @param string $encoding Encoding of the file
*
* @return string
*
* @since 1.0.0
*/
private function encodeFile(string $path, string $encoding = EncodingType::E_BASE64) : string private function encodeFile(string $path, string $encoding = EncodingType::E_BASE64) : string
{ {
if (!\is_readable($path)) { if (!\is_readable($path)) {
@ -1103,6 +1164,16 @@ class Mail
return $this->encodeString($content, $encoding); return $this->encodeString($content, $encoding);
} }
/**
* Encode text as base64 multibye
*
* @param string $text Text to encode
* @param string $lb Linebreak
*
* @return string
*
* @since 1.0.0
*/
private function base64EncodeWrapMb(string $text, string $lb = "\n") : string private function base64EncodeWrapMb(string $text, string $lb = "\n") : string
{ {
$start = '=?' . $this->charset . '?B?'; $start = '=?' . $this->charset . '?B?';
@ -1133,4 +1204,9 @@ class Mail
return \substr($encoded, 0, -\strlen($lb)); return \substr($encoded, 0, -\strlen($lb));
} }
private function encodeQ(string $text, int $context = HeaderContext::TEXT) : string
{
}
} }