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 = "[email protected]";
$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.