Giter Site home page Giter Site logo

Comments (12)

petrus9 avatar petrus9 commented on July 4, 2024

This is how it actually shows up in the error screen:

image

from grav-plugin-email.

rhukster avatar rhukster commented on July 4, 2024

If this provided contact.md is using the same configuration file from you other issue, there was no value for {{ config.plugins.email.from }} nor {{ config.plugins.email.to }}. These were both empty. These need to be provided i a valid email format: https://github.com/getgrav/grav-plugin-email?tab=readme-ov-file#specifying-email-addresses

You said you use "Name lastname <[email protected])>" so I tested with:

process:
    email:
        subject: "[Site Contact Form] {{ form.value.name|e }}"
        from: "Name lastname <[email protected]>"
        to: "Name lastname <[email protected]>"
...

And it worked totally 100% fine. Even without the quotes its fine:

process:
    email:
        subject: "[Site Contact Form] {{ form.value.name|e }}"
        from: Name lastname <[email protected]>
        to: Name lastname <[email protected]>

FYI, you should always include a reply_to: so when you receive an email from the contact form, you can click 'reply' and it will go to the user who entered the form data on your site. Something like:

reply_to: {mail:"{{ form.value.email }}", name:"{{ form.value.name|e }}"}

is the best solution assuming your form has a field for email and for name.

from grav-plugin-email.

petrus9 avatar petrus9 commented on July 4, 2024

Thanks for the reply_to tip. I implemented it and it works!

Here is my new email.yaml

enabled: true
from: 'John Doe <[email protected]>'
to: 'Jane Doe <[email protected]>'
mailer:
  engine: sendgrid
  smtp:
    server: localhost
    port: 25
    encryption: none
    user: null
    password: null
  sendmail:
    bin: '/usr/sbin/sendmail -bs'
content_type: text/html
debug: false
cc: null
bcc: null
reply_to: null
body: null

Which throws the RFC error

Here is my contact.md which I know does not have any lines for "name:" not sure what I need to fix here so that emails are sent to 'Jane Doe [email protected]' and come from 'John Doe [email protected]'

title: Contact
heading: 'Say Hello.'
form:
    action: /home
    name: contact-form
    fields:
        -
            name: name
            label: Name
            placeholder: Name
            type: text
            validate:
                required: true
        -
            name: email
            label: Email
            placeholder: Email
            type: email
            validate:
                required: true
        -
            name: message
            label: Message
            placeholder: Message
            type: textarea
            rows: 6
            validate:
                required: true
        -
            name: g-recaptcha-response
            label: Captcha
            type: captcha
            recaptcha_not_validated: 'Captcha not valid!'
    buttons:
        -
            type: submit
            value: 'Send Message'
    process:
        -
            captcha: true
            buttons: null
        -
            type: submit
            value: 'Send Message'
            process: null
        -
            email:
                from:
                    mail: '{{ config.plugins.email.from }}'
                to:
                    mail: '{{ config.plugins.email.to }}'
                reply_to:
                    mail: '{{ form.value.email }}'
                    name: '{{ form.value.name|e }}'
                subject: '[Contact] Message from {{ form.value.name|e }}'
                body: '{% include ''forms/data.html.twig'' %}'
        -
            save:
                fileprefix: contact-
                dateformat: Ymd-His-u
                extension: txt
                body: '{% include ''forms/data.txt.twig'' %}'
        -
            display: thank-you

from grav-plugin-email.

rhukster avatar rhukster commented on July 4, 2024

OH, change your email process: email: section to:

-
            email:
                from: '{{ config.plugins.email.from }}'
                to: '{{ config.plugins.email.to }}'
                reply_to:
                    mail: '{{ form.value.email }}'
                    name: '{{ form.value.name|e }}'
                subject: '[Contact] Message from {{ form.value.name|e }}'
                body: '{% include ''forms/data.html.twig'' %}'

You were setting the 'email' only part (mail:) with the combined email + name. Just set to: and from: and you should be fine.

from grav-plugin-email.

petrus9 avatar petrus9 commented on July 4, 2024

when I change the process: email: section to your recommendation. I get:

Symfony\Component\Mime\Exception\RfcComplianceException thrown with message "Email "Jane Doe <[email protected]>" does not comply with addr-spec of RFC 2822."

I am assuming I have to add some kind of name field, right?

I am following the the formating given in the email plugin interface:

Screenshot 2024-04-24 152424

from grav-plugin-email.

rhukster avatar rhukster commented on July 4, 2024

So you have quotes around it? Try removing. Maybe they are not regular quotes.

from grav-plugin-email.

petrus9 avatar petrus9 commented on July 4, 2024

So you have quotes around it? Try removing. Maybe they are not regular quotes.

No quotes

from grav-plugin-email.

rhukster avatar rhukster commented on July 4, 2024

I’m at a loss 🤷‍♂️

works for me when I try.

from grav-plugin-email.

petrus9 avatar petrus9 commented on July 4, 2024

The way it shows up on my screen is like this:

Screenshot 2024-04-24 153150

from grav-plugin-email.

rhukster avatar rhukster commented on July 4, 2024

Ya that’s weird. The escaping isn’t right. But I don’t even know how you could do that from a yaml configuration.

from grav-plugin-email.

petrus9 avatar petrus9 commented on July 4, 2024

The only way I get it to work is if my email.yaml looks like this:

enabled: true
from: '[email protected]'
to: '[email protected]'
mailer:
  engine: sendgrid
  smtp:
    server: localhost
    port: 25
    encryption: none
    user: null
    password: null
  sendmail:
    bin: '/usr/sbin/sendmail -bs'
content_type: text/html
debug: false
cc: null
bcc: null
reply_to: null
body: null

from grav-plugin-email.

petrus9 avatar petrus9 commented on July 4, 2024

@rhukster so from what you wrote above, it sounds like when you add name and email address to the Email plugin fields like so:

Screenshot 2024-04-24 162040

Using:

email:
                from: '{{ config.plugins.email.from }}'
                to: '{{ config.plugins.email.to }}'
                reply_to:
                    mail: '{{ form.value.email }}'
                    name: '{{ form.value.name|e }}'
                subject: '[Contact] Message from {{ form.value.name|e }}'
                body: '{% include ''forms/data.html.twig'' %}'        

Your email is delivered coming from John Doe <[email protected]> and is sent to Jane Doe ,<[email protected]> in full

in full name-addr format? is that what you mean by that you can't replicate this?

from grav-plugin-email.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.