As done in Magento 1.x.x, how can custom transactional emails be sent.


  • Add email in bcc

  • Send attachment along email

  • I would suggest to take a look at Contact Module.
    – MagePsycho
    Oct 28, 2015 at 12:34
  • Yes I studied that and answered it below, for sharing purposes
    – huzefam
    Oct 28, 2015 at 12:56

3 Answers 3


okie bit of debugging helps,

Sending a transactional email in Magento2

class Dummy

     * @var  \Magento\Framework\Mail\Template\TransportBuilder
    private $_transportBuilder;

  public function __construct( \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder){

    $this->_transportBuilder = $transportBuilder;

  public function sendEmail($templateId =1, $storeId =1,$templateParams)

     $transport = $this->_transportBuilder->setTemplateIdentifier($templateId)
            ->setTemplateOptions(['area' => Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId])


Magento 2 Uses \Magento\Framework\Mail\Template\TransportBuilder class for send custom email.

You need to create a simple module and set email_tempaltes.xml file for defining your transaction mail templates.

You can send mail from Adminhtml or Frontend Scope area.

I have shared a link for step by step guide to send a custom mail from Magento 2 using a module.

Send Custom Mail from Magento 2 Module


it's working for me

$emailTemplateVariables = array();
$emailTempVariables['myvar'] = $myvar;

$senderName = 'test';
$senderEmail = 'sender@test.com';
$postObject = new \Magento\Framework\DataObject();
$sender = [
        'name' => $senderName,
        'email' => $senderEmail,

$transport = $this->_transportBuilder->setTemplateIdentifier('myemail_email_template')
->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])
->setTemplateVars(['data' => $postObject])

more info

how to send custom email no template in magento2?


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.