magento2 send email programmatically without template
Magento 2: The simplest way I found to send a plain text - use Zend1 mail
$to = ['[email protected]', '[email protected]'];
$email = new \Zend_Mail();
$email->setSubject("Feedback email");
$email->setBodyText($body);
$email->setFrom($from, $nameFrom);
$email->addTo($to, $nameTo);
$email->send();
You can send mail using Zend_Mail()
function.
$firstname = "xxx";
$lastname = "yyyyyy";
// Send Mail functionality starts from here
$from = "[email protected]";
$nameFrom = "From Name";
$to = "[email protected]";
$nameTo = "To Name";
$body = "
<div>
<b>".$firstname."</b>
<i>".$lastname."</i>
</div>";
$email = new \Zend_Mail();
$email->setSubject("Email Subject");
$email->setBodyHtml($body); // use it to send html data
//$email->setBodyText($body); // use it to send simple text data
$email->setFrom($from, $nameFrom);
$email->addTo($to, $nameTo);
$email->send();