Add ability to configure arbitrary mail headers.

Specifically, we'd like to be able to set the reply-to header for feedback e-mails and such. But it would be nice to be able to set any mail header, including the non-standard ones.

Comments

rowbotony’s picture

StatusFileSize
new16.76 KB

I am using Entity forms, and also have the need to add a "reply-to" header. My clients receive an Entity form notification email from their visitors, and they want to "reply to" from their email software, this patch resolves this issue for me.

I spent a few hours today testing Entity form 2.x with variable_email and I have found that, as of this posting, the variable_email -dev branch does not work, all of my tokens come through in the message as the token (example: [entityform:field-contact-email-address]), and wouldn't be converted to the variable value.

To make a long story short - I have been able to add a reply-to to variable_email-7.x-1.x-alpha1 and I'm using it in production with entity_form-7.x-1.4. It seems drupal_mail is similar to PHP mail(), and drupal_mail gladly accepts $reply, so that's what this patch adds. It adds a "Reply To" box on the "Send mail with Variable" action UI form.

variable_email reply-to header

rowbotony’s picture

forgot to add the patch to the last post :(. I did not test this with variable_email-7.x-1.x-dev as the -dev branch was quite broken for me in my use case. This patch is for variable_email-7.x-1.x-alpha1 only.

giupenni’s picture

Thank you for your post.
This can work with Entity Form 2?
In "Send mail with Variable" in "Select the variable which should be used as a template" box what I should choose?

Thank you in advance.

giupenni’s picture

+1 this works with Entity Form 1

giupenni’s picture

Is possibile solve this issue with EntityForm 2 ?

ziobudda’s picture

Any news for EntityForm 2.x and reply-to set to email field ?

Thanks.

M.

giupenni’s picture

I think there is not chance (last commit is been 2 years ago) and unfortunately Entity Form 1.x is not works always correctly.

I'm thinking to switch to webform with some patch (or module) to implement (with some trick) some kind of reference (note title, nid, ....).

noahzenzen’s picture

Hello, I'm currently using rules to send emails (via Mime Mail module as I want them to be HTML emails) and am using the reply-to feature (Rules version = "7.x-2.9"). For the most part it works great. The one issue I'm having is that it's actually putting in two email address when someone hits the reply button in their email client.

I am using tokens to grab an email from a content type field, that toke goes in the Reply-to field. That works. That being said the other email is my "noreply@" email address that's configured for my site. Is there a way to not have the site email address be included in the reply-to? For the life of me I can't find a setting to either include or exclude it. I'm wondering if it's a bug as the help note says that if the field is left blank it will use the sites default email address.

Has anyone else run into this? Am I posting in the wrong place?

Thanks!

leendertdb’s picture

StatusFileSize
new1.09 KB

I tried to use the patch from #2, however it didn't seem to work for us.

The original patch adds a $reply parameter to the drupal_mail function, as can be seen here (at the end):

+  $message = drupal_mail('variable_email', $key, $to, language_default(), $params, $from, $reply);

However the drupal_mail function (at least in the latest 7.x core branch) does not accept a "$reply" variable in that location as can be seen in the API docs:
7.x mail.inc drupal_mail($module, $key, $to, $language, $params = array(), $from = NULL, $send = TRUE)

Attached patch (applies to 7.x-1.x-dev) fixes this by passing in the reply-to variable as a proper header.

leendertdb’s picture

Status: Active » Needs review

Updating status to "Needs review".

leendertdb’s picture

StatusFileSize
new2.13 KB

I noticed the previous patch (#9) was missing a part of the original patch. Updated patch attached.

geek-merlin’s picture

Good idea. Unfortunately i fear this breaks existing rules?

g33kg1rl’s picture

The patch from #11 is not applying cleanly the latest version for 7.x. I really must have this feature. Any updates?

szeidler’s picture

@13g33kg1rl: Use the -dev version of the module. There the patch applies cleanly and works like charm.

Good idea. Unfortunately i fear this breaks existing rules?

As far as I can see, it shouldn't break the existing rules. But it's wise to resave them, of course. When "Reply-To" is empty, it should be simply ignored.

solideogloria’s picture

I created a patch that allows any header to be added. The field lets you enter a valid JSON array, and it will be decoded and added to the message headers.

As an example, I used this to set the message's importance to "High":

{"X-Priority":"1 (Highest)","X-MSMail-Priority":"High","Importance":"High"}

It might be good to add a watchdog message or error of some kind if the entered value isn't valid.