I want to add field value as email subject in Magento2.2.5(Refer screenshot)

enter image description here

Here subject field is a select field, if I select option-1 value, The selected value should be the subject for the email to be sent for the contact form.

Any help would be appreciated.

  • Is it contact form? Mar 14 '19 at 12:39
  • Yes, it is contact form.
    – Amy
    Mar 14 '19 at 12:40
  • plz check my answer and let me know if it helps. ! Mar 15 '19 at 6:16
  • Thank you Manashvi, it is working perfectly fine..
    – Amy
    Mar 15 '19 at 6:18

Overide the email template file located at vendor\magento\module-contact\view\frontend\email\submitted_form.html by placing it into your custom theme at below location :


and change the subject like below :

 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
<!--@subject {{var data.subject}} @-->
<!--@vars {
"var data.comment":"Comment",
"var data.email":"Sender Email",
"var data.name":"Sender Name",
"var data.telephone":"Sender Telephone"
} @-->

{{template config_path="design/email/header_template"}}

<table class="message-details">
        <td><b>{{trans "Name"}}</b></td>
        <td>{{var data.name}}</td>
        <td><b>{{trans "Email"}}</b></td>
        <td>{{var data.email}}</td>
        <td><b>{{trans "Phone"}}</b></td>
        <td>{{var data.telephone}}</td>
<p><b>{{trans "Message"}}</b></p>
<p>{{var data.comment}}</p>

{{template config_path="design/email/footer_template"}}

NOTE Here {{var data.subject}} is used, assuming that the name of the select box in the contact us form is subject

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.