"Message Template" setting
This could be used to customize the body contents, such as include the sender's email address within the message body.
+1
Hah, I don't even remember posting this FR, but worth mentioning that a plugin can take over the message rendering using the beforeMessageCompile event (v1) or beforeSend event (v2).
I know that... But it seems to be hard to achieve and kind of buggy.
I mean, the advantage over other add-ons it's that it's free and easy... If I'd had to customize it, there's no point in using this add-on.
Hiding the reply email and name within the "reply to" field is just not so very natural... Having the name and email address within the body is much more failsafe, logic and it's easy to implement... Even for me :)
It's just adding:
$email->htmlBody = '<p>Name: '.$message->fromName.'</p>';
$email->htmlBody .= '<p>Email Adresse: '.$message->fromEmail.'</p>';
before
// Prevent Twig tags from getting parsed
// add the "." before "=" when customizing this
$email->htmlBody .= str_replace(array('{', '}'), array('{', '}'), $message->htmlMessage);
+💯
@outline4 thanks
$email->htmlBody = '<p>Name: '.$message->fromName.'</p>';
$email->htmlBody .= '<p>Email Adresse: '.$message->fromEmail.'</p>';
@outline4 Where did you add these lines??
Please include such functionality. Honestly, its pretty much basic thing to have in any contact form plugin.
A template would be nice. A little enchantment for now; https://github.com/craftcms/contact-form/pull/161
@KevinBeckers I just wrote a simple Craft CMS module to solve this problem, if it's of interest. It can probably be done in a far more elegant way, but this works for my use case. https://github.com/LukePeters/contactformextras
+1 A way to set a template for the email body is a pretty basic requirement and the body now is pretty primitive. I'm surprised it's not possible with this plugin with Craft having a full Twig template system on board.
Yes please, the ability to set a template would be very useful!
@brandonkelly
Hah, I don't even remember posting this FR, but worth mentioning that a plugin can take over the message rendering using the beforeMessageCompile event (v1) or beforeSend event (v2).
I'm trying to do this with the beforesend event but this doesn't seem to do anything at all. When following the code of contact-form v2, the message is already compiled before this event is fired. Also, there is a foreach on line 119 in Mailer.php which is not using the $event->message. So am i correct when saying this is impossible to achieve?
N.V.M. i made a stupid assumption/mistake.
Here is the code for people who want to achieve the same.
Event::on(Mailer::class, Mailer::EVENT_BEFORE_SEND, function(SendEvent $e) {
// Change whatever you want in your submission data ($e->submission->message)
$e->message->setTextBody($text);
$e->message->setHtmlBody($html);
});