Forms: Support display name for the "from" sender
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.
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
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
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:
- It was supported by v1, so it’s a regression.
- 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.
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.
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! 😊
@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.
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