Skip to content

Instantly share code, notes, and snippets.

View mucan54's full-sized avatar

Can Özdemir mucan54

View GitHub Profile
@mucan54
mucan54 / mailsend.php
Created February 18, 2020 13:00
Magento2 Mail Send
public function _mailSend($array,$mailBody){
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$htmlconvert=$objectManager->create('\Magento\Framework\Mail\MessageInterface');
$transport=$objectManager->create('\Magento\Framework\Mail\Transport');
$htmlconvert->setBody($mailBody);
$htmlconvert->addTo($array["to"]);
$htmlconvert->addCc($array["cc"]);
$htmlconvert->addBcc($array["bcc"]);
$htmlconvert->setSubject($array["mail_subject"]);
$htmlconvert->setFrom($this->scopeConfig->getValue('trans_email/ident_support/email',ScopeInterface::SCOPE_STORE));
@mucan54
mucan54 / htmlconvert.php
Last active February 18, 2020 13:00
Magento2 HTML mail send
public function _mailBodyHTML($body){
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$zendPart=$objectManager->create('\Zend\Mime\Part');
$zendMessage=$objectManager->create('\Zend\Mime\Message');
$zendPart->__construct($body);
$zendPart->setType("text/html");
return $zendMessage->setParts(array($zendPart));
}