Custom email using the email plugin?

How do i go about creating a custom email template when using the email plugin? Could anyone point me in the direction of a good guide?

You can see from the docs, that to process email with a custom twig template, you simply need to pass the path of the relevant twig you wish to use. You can use the ones included in the email plugin as good place to start:

You just need to put these into your Twig template path somewhere. Either in your theme, or in a custom plugin that provides these templates.

Is there an example of one the the forms/default/data.html.twig that i could see, its setting out the content of the email i would like to see really. How would i get data sent into an email?

That is provided by the Form plugin:

You can put that file in your theme templates/ folder (mind the folder structure) and customize it.

Thats for building the form is it not? I want to customise the actual email that is sent out.

I think i may have pasted the wrong twig file above? Is not exactly a very user friendly way of creating contact forms, and their respective emails haha :slight_smile:

I think I misunderstood the question.

You can use the Email plugin to send the result of a form submit, see the example Contact form. In that example, you can set the Twig used by the email to render the data.

That was working with forms to send emails, which is the way you usually interact with that plugin.

If all you want to do is instead customize the overall template layout, and not the content, you can add to your theme the file templates/email/base.html.twig from here and customize it.

The reason you have to put it in your theme is, you don’t need to worry when updating the plugin, your changes will be safe. Of course then the problem is redirected to the theme, this is why you should create your own inherited theme, next thing.

Cheers for that Flavio, so how do i change the layout of the content of the email? I have see that it simply replicates the form layout, so for the contact for it shows, name: email: and message: What would i need to edit to change the layout of that email?

Ok so if you’re editing the contact form output, you move this file in your theme, and customize how the data is rendered. You can all it however you like, and then include that in your form action, where you see

        - email:
       subject: "[Site Contact Form] {{|e }}"
       body: "{% include 'forms/data.html.twig' %}"

so to change the layout of the email, i just access the form items using {{|e }} for example? I think i have it now. i will just mess with it and see what i can come up with now :slight_smile: thanks

I would like to receive emails as html format when someone use the contact form. Is it possible to call an email template file?

Emails are sent in HTML format, using this template:

You can customize that in your theme.