v2-hub icon indicating copy to clipboard operation
v2-hub copied to clipboard

Forms: Support display name for the "from" sender

Open alehandrof opened this issue 7 years ago • 7 comments

Describe the bug When trying to send an email with an address formatted like this Firstname Lastname <[email protected]> I receive this error:

Swift_RfcComplianceException in MailboxHeader.php line 345:
Address in mailbox given [Firstname Lastname <[email protected]>] does not comply with RFC 2822, 3.6.2.

To Reproduce Create form that will send an email that includes a contact__name and a contact__email and try to send it.

Here's an example of the configuration I used:

title: Profile email
fields:
  contact__name:
    display: Name
    validate: required
  contact__email:
    display: Email
    validate: required|email
  contact__message:
    display: Message
    validate: required
columns:
  - contact__name
  - contact__email
  - contact__message
email:
  -
    to: "[email protected]"
    from: '{{ contact__name }} <{{ contact__email }}>'
    subject: "Message from {{ contact__name }}"

Expected behavior This format should be accepted as valid.

alehandrof avatar Aug 31 '18 13:08 alehandrof

FYI - I had opened a forum post earlier that may include some more information: https://statamic.com/forum/3479-issues-with-a-form-s-email-notification

alehandrof avatar Sep 04 '18 14:09 alehandrof

Alas that feature doesn't support setting an email and name together. It needs to be just the email address.

https://docs.statamic.com/forms#emails

jackmcdade avatar Sep 14 '18 14:09 jackmcdade

Instead of closing this issue, can you recategorize it as a feature request?

There are two good reasons for supporting the both name and email together, besides the fact that it’s a common standard:

  1. It was supported by v1, so it’s a regression.
  2. Including the name helps with deliverability, which is especially important in the case of transactional email, as such messages often end up in junk folders.

alehandrof avatar Sep 16 '18 19:09 alehandrof

Yes, we can call it a feature request, that's fine. But just FYI, it's not a regression because Raven was a separate paid addon, and Forms is included. It's not hooked up because the email library does not easily support it, so it would take us writing regex to pull the name out of the brackets and all that. I would much prefer to have a separate "name" field than support that format. 2. True, but it still falls back to your site config name, so it's not going to be empty. You're also sending it to yourself/internally, so those details do matter less because you can control them.

Just giving you my whole thought process as to why I clicked close so i could keep working on getting v3 out the door.

jackmcdade avatar Sep 17 '18 13:09 jackmcdade

You're right about the regression language. I don't think that was helpful. I'm sorry!

I prefer the idea of having a separate name field as well.

I use the forms functionality to have people send emails to my site's users from the front-end of the site, so the messages come from, and go to, people who are not associated with the site's administration at all.

By all means keep plugging away at v3. I thought that it would be helpful of keeping the issue open as a reminder for v3 when it launches, because presumably some issues will need to be carried over there. I didn't mean to attempt to dictate what you work on! 😊

alehandrof avatar Sep 18 '18 09:09 alehandrof

@jackmcdade - Is adding form_name & form_email to the configuration options of a form something that I can contribute to? It's a feature I'm in need of right now, and would like to contribute to resolve it if possible.

philliphartin avatar Nov 20 '19 10:11 philliphartin

Came up against this too so I'm offering up a workaround that's suits my needs.

Set the from: key to have a capital letter at the start. Gmail (and I suspect others) will then show this as the sender name in the inbox.

email:
  -
    to: "{{ email }}"
    from: [email protected]
    reply_to: [email protected]
    subject: Enquiry from {{ email }}
    template: enquiry

wesort avatar Mar 24 '20 19:03 wesort