5

When order confirmation send all content contain this

=0D=0A=0D=0A=0D=0A =0D=0A

Here is email screenshot:

enter image description here

app\Vendor\Extension\etc\di.xml

<preference for="\Magento\Sales\Model\Order\Email\SenderBuilder" type="Vendor\Extension\Model\Template\SenderBuilder"/>

Here is Vendor\Extension\Model\Template\SenderBuilder\send.php

Here is my send function for PDF attache

public function send()
    {
        $objectManager = ObjectManager::getInstance();
        $configHelper = $objectManager->get(Data::class);
        if ($configHelper->versionCompare("2.3")) {
            # attach pdf, overide send function
            $attachPdf = $this->attachPDF();
            $this->configureEmailTemplate();
            $this->transportBuilder->addTo(
                $this->identityContainer->getCustomerEmail(),
                $this->identityContainer->getCustomerName()
            );
            $copyTo = $this->identityContainer->getEmailCopyTo();
            if (!empty($copyTo) && $this->identityContainer->getCopyMethod() == 'bcc') {
                foreach ($copyTo as $email) {
                    $this->transportBuilder->addBcc($email);
                }
            }

            #transport email
            $transport = $this->transportBuilder->getTransport();
            $html = $transport->getMessage();
            $message = Message::fromString($html->getRawMessage());
            $bodyMessage = new \Zend\Mime\Part($message->getBody());
            $bodyMessage->type = 'text/html';
            $bodyMessage->charset = 'utf-8';
            $bodyPart = new \Zend\Mime\Message();
            $bodyPart->setParts([$bodyMessage, $attachPdf]);

            #transport email with body part
            $transport->getMessage()->setBodyHtml($bodyPart);
            $transport->sendMessage();
        } else {
            $this->attachPDF();
            parent::send();
        }
    }
3
  • can share code by which you are sending mail? – Padhiyar Gaurang Dec 9 '19 at 13:37
  • 1
    @chirag please share your code, its looks like the headers are changed, please check the header information, and check the encoding type. From the screen shot I can say the encoding is change. =0D is a Carriage Return (CR), =0A is a Line Feed (LF), and =0D=0A is a CRLF combination displays when encoding or any external event happen which cause the change. Please share your code for more debugging – Ashish Ranade Dec 9 '19 at 13:48
  • Hello, @AshishRanade Here add code please check it. – Chirag Gondaliya Dec 9 '19 at 14:06
1

removing these lines in lib/internal/Magento/Framework/Mail/Message.php

  $part->setEncoding(Mime::ENCODING_QUOTEDPRINTABLE); $part->setDisposition(Mime::DISPOSITION_INLINE);

Other thing is set encoding of message properly. See this method at

vendor\zendframework\zend-mime\src\Mime.php

public static function encode($str, $encoding, $EOL = self::LINEEND)
{
    switch ($encoding) {
        case self::ENCODING_BASE64:
            return static::encodeBase64($str, self::LINELENGTH, $EOL);

        case self::ENCODING_QUOTEDPRINTABLE:
            return static::encodeQuotedPrintable($str, self::LINELENGTH, $EOL);

        default:
            /**
             * @todo 7Bit and 8Bit is currently handled the same way.
             */
            return $str;
    }
}

If your email part message is encoded 'quoted-printable' than it will call encodeQuotedPrintable method which ultimately call private method _encodeQuotedPrintable where line $str = str_replace(static::$qpKeys, static::$qpReplaceValues, $str); replaced those =0D=0A=0D=0A=0D=0A =0D=0A type of strings.

private static function _encodeQuotedPrintable($str)
{
    // @codingStandardsIgnoreEnd
    $str = str_replace('=', '=3D', $str);
    $str = str_replace(static::$qpKeys, static::$qpReplaceValues, $str);
    $str = rtrim($str);
    return $str;
}

Where $qpReplaceValues variable values are below. which are current string in your email part.

 public static $qpReplaceValues = [
    "=00","=01","=02","=03","=04","=05","=06","=07",
    "=08","=09","=0A","=0B","=0C","=0D","=0E","=0F",
    "=10","=11","=12","=13","=14","=15","=16","=17",
    "=18","=19","=1A","=1B","=1C","=1D","=1E","=1F",
    "=7F","=80","=81","=82","=83","=84","=85","=86",
    "=87","=88","=89","=8A","=8B","=8C","=8D","=8E",
    "=8F","=90","=91","=92","=93","=94","=95","=96",
    "=97","=98","=99","=9A","=9B","=9C","=9D","=9E",
    "=9F","=A0","=A1","=A2","=A3","=A4","=A5","=A6",
    "=A7","=A8","=A9","=AA","=AB","=AC","=AD","=AE",
    "=AF","=B0","=B1","=B2","=B3","=B4","=B5","=B6",
    "=B7","=B8","=B9","=BA","=BB","=BC","=BD","=BE",
    "=BF","=C0","=C1","=C2","=C3","=C4","=C5","=C6",
    "=C7","=C8","=C9","=CA","=CB","=CC","=CD","=CE",
    "=CF","=D0","=D1","=D2","=D3","=D4","=D5","=D6",
    "=D7","=D8","=D9","=DA","=DB","=DC","=DD","=DE",
    "=DF","=E0","=E1","=E2","=E3","=E4","=E5","=E6",
    "=E7","=E8","=E9","=EA","=EB","=EC","=ED","=EE",
    "=EF","=F0","=F1","=F2","=F3","=F4","=F5","=F6",
    "=F7","=F8","=F9","=FA","=FB","=FC","=FD","=FE",
    "=FF"
];
8
  • We not found this file lib/internal/Magento/Framework/Mail/Message.php – Chirag Gondaliya Dec 9 '19 at 14:41
  • @ChiragGondaliya Check updated answer. It will help you to understand the problem. – Padhiyar Gaurang Dec 10 '19 at 5:38
  • Now what to do in my code for solution for this issue. – Chirag Gondaliya Dec 10 '19 at 5:46
  • @ChiragGondaliya Set encoding and set disposition setEncoding('base64') and setDisposition('inline') and if that also does not solve than setEncoding('quoted-printable') and setDisposition('inline') – Padhiyar Gaurang Dec 10 '19 at 5:55
  • I try set encoding and disposition but not work. – Chirag Gondaliya Dec 10 '19 at 5:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.