I have overridden the webform mail(webform-mail-19.tpl.php) template in my theme. The problem is I want to set the recipient in this template file so I used this code. $email['email'] = 'example@example.com' but it did not send email to this address instead it sends email to the email address which i setup in the email settings of the webform.

I print the $email array and I could see "example@example.com" email there but did not know why it sends the email to the default email address which is setup at the email settings of the webform.

Any Idea about this?


You cannot set the recipient in a template file, these files are only used for the theme layer. The templates only control the display of information.

The recipient email must be set on the settings page of the webform.


You can implement following step for the mail setting.

  • Add a hidden component in the webform.
  • In the webform mail setting page, you can set hidden component as mail to address.
  • You can override the value of hidden component in webform mail template.

I have done it using hook_mail_alter

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .