I am facing quite known issue about sending mail via TransportBuilder. I need to send mail in observer, however each time I try I get error
Unable to send email. Unknown error . I can reject any server configuration, because email mechanizm is working in any other way ( orders, registration, newsletter etc. ), so I belive there must be something wrong with my code. Also my
$transportBuilder construction is almost copied from other modules .
1.) I’ve created template in
2.) I’ve created template in
3.) My $transportBuilder is looking like this
$this->inlineTranslation->suspend(); $transport = $this->transportBuilder ->setTemplateIdentifier($templateId) // passed from id in email_templates.xml ->addTo($customerEmail, $customerName) ->addBcc($bccEmail) ->setTemplateOptions( ( 'area' => Area::AREA_FRONTEND, 'store' => $storeId, ) ) ->setTemplateVars(( 'customer' => $customer )) ->setFromByScope('general') ->getTransport(); $transport->sendMessage(); $this->inlineTranslation->resume();
I’ve noticed error is thrown at
/vendor/magento/module-email/Model/Transport.php:101 , excalty by zend vendor/zendframework/zend-mail/src/Transport/Sendmail.php:mailHandler() , however no more specific error message is shown.
I am sure that my local enviroment is working good as other mails are sent properly. Maybe I’ve missed something in my new module ? I’ve spent many hours on this issue and I am still stuck, so I’ll be very grateful for some help.