I try to add mail subject in my custom mail, but i can't find anything about this.

My code for sending emails looks like this:

$from = array('email' => "info@info.nl", 'name' => 'info');
$transport = $this->_transportBuilder->setTemplateIdentifier('medipoint_template_lend')
    ->setTemplateVars(['data' => $postObject])

Does anyone know how to add subject to maill?


Usually you have to use an email template. The subject is then defined inside that template using something as such

<!--@subject Subject Of your email  @-->

In our module we used a helper to get the custom template and send the email.

| improve this answer | |
  • so i just need to add <!--@subject [subject] @--> at the begining of email template? – Alin Lupoiu Mar 8 '17 at 11:37
  • i did this but nothing happen – Alin Lupoiu Mar 8 '17 at 12:14

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.