2

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? – Sameer Bhayani Mar 14 at 12:39
  • Yes, it is contact form. – Amy Mar 14 at 12:40
  • plz check my answer and let me know if it helps. ! – Manashvi Birla Mar 15 at 6:16
  • Thank you Manashvi, it is working perfectly fine.. – Amy Mar 15 at 6:18
0

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 :

app\design\frontend\Custom\Theme\Magento_Contact\email\submitted_form.html

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">
    <tr>
        <td><b>{{trans "Name"}}</b></td>
        <td>{{var data.name}}</td>
    </tr>
    <tr>
        <td><b>{{trans "Email"}}</b></td>
        <td>{{var data.email}}</td>
    </tr>
    <tr>
        <td><b>{{trans "Phone"}}</b></td>
        <td>{{var data.telephone}}</td>
    </tr>
</table>
<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.