Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mail sent not formatted properly #38

Closed
edwigemorin opened this issue Sep 19, 2016 · 7 comments
Closed

Mail sent not formatted properly #38

edwigemorin opened this issue Sep 19, 2016 · 7 comments

Comments

@edwigemorin
Copy link

edwigemorin commented Sep 19, 2016

Hello,

When a comment is made the mail received is showing code not interpreted.

Mail object : PLUGIN_COMMENTS.EMAIL_NEW_COMMENT_SUBJECT

Mail body : 
<div>
<strong>PLUGIN_COMMENTS.NAME_LABEL</strong>:
name
</div>
<div>
<strong>PLUGIN_COMMENTS.EMAIL_LABEL</strong>:
name@website.com
</div>
<div>
<strong>PLUGIN_COMMENTS.MESSAGE_LABEL</strong>:
bla bla message
</div>
<div>
<strong></strong>:
</div>
<div>
<strong></strong>:
xxxx post title
</div>
<div>
<strong></strong>:
fr
</div>
<div>
<strong></strong>:
/blog/xxx-xxxxx-xxx
</div>

Do I have to do something in the config or is it a bug ?
Thank you in advance.

@flaviocopes
Copy link
Contributor

You mean PLUGIN_COMMENTS.EMAIL_LABEL and other translation strings or the fact that you see HTML markup?

@phideas
Copy link

phideas commented Jan 8, 2017

Same problem. E-mail contains translation placeholders, not translated text.

PLUGIN_COMMENTS.EMAIL_NEW_COMMENT_SUBJECT

PLUGIN_COMMENTS.NAME_LABEL: Visitor3
PLUGIN_COMMENTS.EMAIL_LABEL: visitor3@gmail.com
PLUGIN_COMMENTS.MESSAGE_LABEL: Test comment.
:
: Blog post 1
: en
: /blog/blog-post-1

@flaviocopes
Copy link
Contributor

Are translations enabled in your site? It should be set in the System configuration.

@phideas
Copy link

phideas commented Jan 9, 2017

Yes, translations are enabled in Config. Actually this fix worked for me:
in /user/plugins/email/email.php

 case 'subject':
-                    $message->setSubject($twig->processString($value, $vars));
+                    $message->setSubject($twig->processString($this->grav['language']->translate($value), $vars));
                     break;

in /user/plugins/form/templates/forms/default/data.html.twig

         {% block field %}
             <div>
                 {% block field_label %}
-                    <strong>{{ field.label }}</strong>:
+                    <strong>{{ field.label|t }}</strong>:
                 {% endblock %}
                 {% block field_value %}
                     {{ string(form.value(field.name ?? index))|nl2br }}

Hope it helps. Please submit if good.

@flaviocopes
Copy link
Contributor

Replicated, your proposed fix is right. Going to make 2 separate commits, or if you want you can create a PR with your contribution and I'll merge it.

@phideas
Copy link

phideas commented Jan 12, 2017

Please commit.

flaviocopes added a commit to getgrav/grav-plugin-email that referenced this issue Jan 13, 2017
flaviocopes added a commit to getgrav/grav-plugin-form that referenced this issue Jan 13, 2017
@edwigemorin
Copy link
Author

edwigemorin commented Mar 8, 2017

Hello,
Thank you for your update.
I would like to come back to this issue because there is few more point which are not working for me.

  1. The Subject in the mail received is still not interpreted, subject is always : PLUGIN_COMMENTS.EMAIL_NEW_COMMENT_SUBJECT

  2. In the body of the mail received some labels are missing (coming from hidden fields of the form) that are showed in the mail received. Therefore it would be necessary to add these new label call in the comments.yaml such as :

  • label: PLUGIN_COMMENTS.DATE_LABEL
  • label: PLUGIN_COMMENTS.TITLE_LABEL
  • label: PLUGIN_COMMENTS.LANGUAGE_LABEL
  • label: PLUGIN_COMMENTS.PATH_LABEL
  1. In the mail received the date field is empty

  2. The cherry on the cake would be to have the path to the page where the comment was done with the link in the html mail version.

  3. Another improvement for this plugin would be to have an output as a markdown file and not a yaml (to stay in the philosophy of flat files). I'm not sur this would be possible.
    And an html interpretation with a kind of organisation like this (still do not know if it's possible):

<article class="post">
    <div class="author">
        <div class="avatar"></div>
    </div>
    <div class="post">
        <div class="date"></div>
        <div class="text"></div>
    </div>
</article>

Anyway N°5 would be a huge cherry on the cake ;-)

Thank you for your plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants