0

Getting below error while sending mail with Magento 2.3.2:

Line <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html style="font-size: 62.5%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-size-adjust: 100%; background-color: #f5f5f5;"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <style type="text/css"> does not match header format!

The Code being tried is as Below:

$toemail = "example@example.com";
$emailTempVariables = array('cid'=>$customer->getId(),'cemail'=>$email,'cname'=>$firstname.' '.$lastname);
            $senderName = $firstname.' '.$lastname;
            $senderEmail = $email;
            $postObject = new \Magento\Framework\DataObject();
            $postObject->setData($emailTempVariables);

            $sender = [
                        'name' => $senderName,
                        'email' => $senderEmail,
                      ];

            $transport = $this->_transportBuilder->setTemplateIdentifier('email_template_identifier')
                ->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])
                ->setTemplateVars(['data' => $postObject])
                ->setFrom($sender)
                ->addTo($toemail)
                ->setReplyTo($senderEmail, $senderName)            
                ->getTransport();               
            $transport->sendMessage();

Please help if someone have any idea on it.

1

There was an issue in header template. To resolve this issue, override header.html in your theme

vendor/magento/module-email/view/frontend/email/header.html

and update it. I have fixed it by replacing

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

With

<!DOCTYPE html>

However, more answers are welcome to fix this issue if any other best way is possible.

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.