It would be really great if you could add a preference setting (or make it standard) that would allow the theme-able email output to contain more than just plain text content data. This could be done by simply having and option to have the theme('webform_mail_fields', 0, $form_values['submitted_tree'], $node); output each field item in an unordered list mode. PREFERABLY something themable like this:
<ul>
<li><span class="heading">field one heading:</span> field one's submitted data, etc.</li>
<li><span class="heading">field two heading:</span> field two's submitted data, etc.</li>
<li><span class="heading">field three heading:</span> field three's submitted data, etc.</li>
</ul>
I've actually almost accomplished it in just the theme file, but I can't seem to separate the headings from the submissions when string replacing line-breaks with </li><li> or <br />.
Please help those of us (almost everyone these days) who has HTML outputted email using Mime Mail.
Without this functionality, the output is REALLY difficult to read, due to the lack of real line-breaks or formatting.
| Comment | File | Size | Author |
|---|---|---|---|
| #70 | webform_mimemail7.patch | 17.35 KB | quicksketch |
| #69 | webform_mimemail.patch | 18.66 KB | quicksketch |
| #68 | webform_mimemail.patch | 18.35 KB | quicksketch |
| #67 | webform_mimemail.patch | 18.51 KB | quicksketch |
| #66 | 698494.patch | 13.99 KB | stella |
Comments
Comment #1
quicksketchNo new features are being added to the 2.x version, so this won't happen there.
I'm actually rather glad this issue was raised though, because I've been thinking about how to solve it for a while now. In the 3.x version, we just now got an HTML version of output in #181077: Printable page for webform submissions. Prior to that (I'm sure you're aware) the "View" versions of submissions were just the same form with values prepopulated. We didn't even have a way to output HTML submissions.
Now however we have a standard mechanism for outputting HTML for any component (it actually uses the same mechanism as printing out e-mails, or rendering the form itself). We can easily create HTML e-mails.
In the 3.x version of Webform, e-mail templates are also built into the interface, so situations requiring custom theming will be much less likely. The only area I know of that might cause some trouble is what to do about differences in templating between HTML and Plain Text e-mails. The only way I can think to solve this is to automatically insert line breaks or paragraph tags into templates, so the exact same template would work for both HTML and Plain Text.
To give you an idea of the interface, this is basically what I'm thinking.
So just by checking the box, appropriate headers would be set, and you could use (nearly) any HTML you wanted in the e-mail template. All tokens would immediately convert to their HTML equivalents instead of the text versions. Like I said above, we'd probably run the "Convert line breaks" filter so
<p>tags would be added automatically so the template wouldn't need any changing.Comment #2
quicksketchSorry my screenshot seems to be missing the main token
%email_valueswhich prints out the entire tree of the submission, just like when you view an individual submission through the site.Comment #3
gregarios commentedI like your ideas. However, it is the "entire tree of the submission" that is giving me the most headache... it needs to have tags separating the different submission fields or it won't work.
If people use Mime Mail, your email output won't have a problem because Mime Mail automatically strips all html for a plain-text version anyway. When people get an email, they get a plain-text version AND an HTML version. People who can only see plain-text see that version and everyone else sees the full HTML version.
The problem is that the "Full HTML" version does not have any way to CSS it because the "tree" is just one variable, inserted into the email. Do you understand what I'm getting at?
Comment #4
gregarios commentedAlso, I'm using a home-brewed "Convert line breaks" filter and it doesn't work for text area submissions very well. You end up with emails that have line-breaks correctly done in HTML, but there is no difference between the line-breaks found IN the submissions and the line-breaks found between the submissions. you end up with output that looks great everywhere except in the outputted text. See the screenshot of the best-I-can-CSS-it email.
Even if there were some kind of tag, like divs even, or even some "==========" lines between the submission fields so I could do some string substitutions on it, I could do it in the template itself. Just having HTML line-breaks isn't enough -- you need to be able to CSS some space between the submission fields, bold the fieldname text, etc...
The
%email_valuesitself needs to have html tags.(Of course, I used a spam form submission as my example lol)
Comment #5
quicksketchI should also note if you want you can print out individual fields as %email[field_name]. I'm sure with the appropriate CSS you can output the fields exactly as they show up when displayed in Drupal. If you haven't already, I'd suggest you try out the 3.x version (though on a separate installation or after a database backup, you cannot downgrade). In 2.x you have only plain text to work with. If we output the content of the e-mail AS HTML, that is, exactly the way it is output when viewing the submission through the browser; you have much more control over how things look because they are split up into
<label>and<div>tags, not like when trying to shoehorn plain text into become HTML. In addition, every component is run through the theme system, so you can theme every type individually if you need more control.Comment #6
gregarios commentedIf I submit a patch for 2.x that will do the plaintext-to-html conversion, would you be willing to include it in the 2.x version? I've just about finished, and it just makes a few tiny changes to each of the files in the "components" directory. I've successfully made each field-type output as a list-item. MUCH easier than calling out every possible field by name in every form on the site using "%email[field_name]", wouldn't ya think? I'd have to make one email template for every form... Ugh.
Comment #7
gregarios commentedAs for using the 3.x version... I'm actually using this on a newspaper website, and it cannot be a "don't use on a production site" kind of module. How soon will there be a 3.x version out?
Comment #8
gregarios commentedI guess my thinking is: Don't try to put out plain-text at all. Go ahead and keep your webform-mail.tpl.php templating, but give every plaintext item its own html tags. Let Mime Mail compose the email headers, and convert back into plaintext for those who don't see HTML mail. Mime Mail already does that part really well. You can't have forms and many other types of HTML tags in emails anyway, so displaying it "just like" the display you're using online won't work -- the emails will be labeled as spam most of the time. Keep the HTML output simple, by letting individuals create the templates, but output simple unordered lists of the data that can be styled in CSS. :-)
Comment #9
quicksketchI won't be supporting 2.x with any new features. I anticipate the 3.x version will have a beta here in a few weeks, with the final version about 2 months out, hopefully around the same time D7 comes out.
Comment #10
gregarios commentedPlease, if you could look into this for just a sec. I've created a patch that will add the capability of outputting the form as simple unordered lists with classes in the email. I also made sure that the default setting in the template would not change how the module works as it stands now.
The patch attached to this post will make modifications to the files, and allow the theme to use either HTML or Plain Text output... strictly from the theme. Please take a look, and if you would, include my patch into a new release so people can start enjoying html output even in version 2.x. I've made sure it should produce NO problems or extra support for you, since it doesn't change the way anything really works. You would be able to announce that version 2 has HTML output capability optional from the theme.
To apply the patch, cd into a fresh 2.9 version root, place the patch in it, and run
patch -p0 < webform_html_patch_20100129a.patchto patch it.Attached are screenshots of the "Before" and "nl2br tag only" and "After" effect of being able to CSS the output in the emails. Your module can produce this kind of output rather easily, without a complete rewrite. (After patching, the link seen in the "After" is a real link that can be clicked on to retrieve the file)
*** IMPORTANT: SEE PATCH SUBMISSION IN COMMENT #60 FOR VERSION 2.10 PATCH ***
Comment #11
quicksketchHow about this: I'll commit it to the 2.x version if you port it to both 3.x (for Drupal 6) and to the 2.x version for Drupal 5 (since the 2.x branches are maintained in sync). The support of 3 branches simultaneously is what I'm trying to avoid. If you're willing to put in the effort to make it so I don't have to test this in all 3 branches I'll commit it. Please make patches against the latest CVS version, not 2.9, as there have been other fixes to the code since 2.9 was released.
Comment #12
gregarios commentedI don't have CVS access it seems... how do I get these versions to work with?
Comment #13
quicksketchYou don't need a CVS account to get code out of CVS, just use the anonymous/anonymous user and password. See the instructions under the CVS Instructions tab from the Webform project page. http://drupal.org/project/webform/cvs-instructions
Comment #14
gregarios commentedAfter looking into the major differences between the 5.x-2.x and 6.x-2.x versions, as well as the upcoming 6.x-3.x differences, I guess I'm going to have to decline. I'm really disappointed, but my day job doesn't allow me the kind of time it would take for me to do it. I'm just not good enough at PHP yet to pull it off without a ton more time researching, and I've never done anything with CVS.
I'm better off just making the tweaks I need to your existing versions and making it work for me I guess -- redoing the patch after every release if needed. I thought I was doing great making a production-ready patch for ya, but I suppose you're busy too -- sorry.
Comment #15
quicksketchYeah, multiple branches like this is exactly the problem. It's easy to get it working once, but then you have to do it all over again 2 or 3 more times (we'll have 4 branches as soon as I port the 3.x version to Drupal 7). This many branches really isn't manageable, which is why 2.x is deprecated as soon as 3.x comes out and we'll drop support for Drupal 5.
Thanks for the patch presented. It's still useful for reference to see the approach and concept, kind of like a set of instructions for porting.
Comment #16
gregarios commentedComment #17
gregarios commentedComment #18
ShannonK commentedSubscribing
Comment #19
butler360 commentedSubscribing
Comment #20
gregarios commentedAfter looking at the new 6.x-3.0-beta1, I may try porting it to the 3.x branch after all... not for a few weeks though, and only if you'll accept a patch for the -beta or latest -dev version. I don't wish to install a cvs client and figure all that out right now. Would that be good with you quicksketch? My patch can't be ported to the 5.x-2.x version I'm afraid.
Comment #21
quicksketchSuper, sounds great gregarios. The advent of 3.0 will end all support for Drupal 5, so no need to backport to previous versions. Thanks!
Comment #22
gregarios commentedOk, forget weeks. I did it tonight.
Attached is a complete patch for 6.x-3.0-beta1. Install it by placing it in the downloaded and uncompressed "webforms" directory, 'cd' into the directory and run the following in the command-line:
patch -p0 < webform3_html_patch_20100215a.patchThis patch adds HTML output capability to the module, with a new setting under
/admin/settings/webformwhich allows you to set your desired preference for Plain Text or HTML email content output.@quicksketch: Please use these submitted patches at your earliest convenience to get them into new beta releases if you would. :-)
@everyone: Please test and report back.
Note: You still must use a module like Mime Mail to get your email to be in HTML, but these patches make your email body output from this module as an HTML unordered list with classes for easy CSS modification.
Comment #23
quicksketchA list of things that don't seem quite right:
Manually building lists like this isn't common within Drupal, you should be using theme('item_list', $items) when building a UL.
Choices affecting the e-mail output should be made on the e-mail configuration screens, not on the component configuration screens. So for example:
This code doesn't belong in select.inc. It should be part of the e-mail configuration form.
Code that is conditional like below should be performed automatically based on the $email variable available in the templates. Again, the configuration option to send an HTML-email should be configurable per-email, basically as shown in comment #1.
Lastly the "global" HTML e-mail configuration option should simply be a "default" value for the per-email configuration options.
Again, if this isn't ported back to Drupal 5 (which I don't think it should be), this set of changes will only go into the 3.x branch.
Comment #24
gregarios commentedI'm really not a PHP expert... and clearly there are many things I don't know. Can you implement my ideas into the 3.x branch? It may very well take me 3 weeks to fully understand how to "properly" put together the UL, while you could surely do it in an hour or two it seems... Please! :-)
I don't mind if it only sees the light of day in the 3.x branch.
My reason for making the HTML configuration global is that the Mime Mail module, and other HTML mail modules are only global as well. It wouldn't make sense to do it on a per-webform basis.
Comment #25
quicksketchI'm definitely planning on adding HTML-email functionality at some point, though hopefully with this issue as a guide it will speed up the process a bit. I'm not at all familiar with MIME mail though, so I'll need to spend some time understanding how that system works.
Comment #26
gregarios commentedThe Mime Mail module takes ALL outgoing email from a Drupal site, and splits it into an HTML-allowed (by template & css file) body and a Plain-text-body. Those bodies are put back into each email with Mime settings so they can both exists in one email at the same time. Then, people with email clients that can only, or are set to only, see plain text will see only the plaintext version, while other emailers that can render HTML will only show the HTML version.
Your module need not do anything except output as plaintext or as HTML. People who choose HTML and Mime Mail will have dual format emails sent out with both plaintext and HTML versions MIMe'd into it.
As a matter of fact, you shouldn't try to implement HTML Headers in your outgoing email at all, and just require Mime Module for people that want it. The patches I made are just to support that union.
Comment #27
gregarios commentedI didn't build any lists at all... the module already built them that way. I just added the correct tags in the correct spots to make it HTML.
Comment #28
gregarios commentedI think I mentioned before... it is much easier to build an HTML list to begin with, then strip out all the HTML for a plaintext version, than it is to build an HTML list from a plaintext one.
Comment #29
broonThanks a lot for this patch (#10). It's working perfectly and it's just what I was looking for. Saved me a lot of time.
After applying the patch I did some editing to the webform-mail.tpl file and there
$form_valuesis available which contains all submitted data. So if you've got an email field (machine readable name: email) you could access the entered data by calling$form_values['submitted']['email']. And by usingforeach $form_values['submitted'] AS $field_name => $field_valueone doesn't even need to know the machine readable names. I know it's far from being an honest solution but it might help in specific situations or as another starting point of new features.Best,
Paul
Comment #30
gregarios commented@sin.star: Do you see that method as a workable solution for a website with hundreds of different contact and survey forms?
Comment #31
broonOf course not, just as I wrote it's far from being a real solution, especially if you have hundreds of web forms. But for some admins/dev this may be a quick'n'dirty workaround. In my case the current project only needs one form for a event registration and the users receives a copy of it. That's why I needed some styling.
I have several drupal projects running and I am looking forward to version 3 (especially performance since there is a project featuring web forms including a few thousand elements, altering these forms is a real pain in t....).
Comment #32
mparker17Subscribe.
Comment #33
theohawse commentedWow, I just commented on an issue over here: http://drupal.org/node/255356 and it looks like you guys are already on it, maybe you could add an optional span tag with classes on the textfields, this would permanently solve the inline fields problem without css.
Also this whole idea of outputting in lists is awesome! I'm not sure about line breaks and stuff, but [li] and [span] would make a huge world of differance for themers.
In my situation, we're trying to make a finance application and it will need to fit nicely onto a single sheet of paper, with a signature space at the bottom, so having inherent inline fields would just rock!
Have a look at how it's done in cck with the drop-down option to display the label inline, hidden, or above. (span, none, div).
Comment #34
adrianmak commentedcould I put a site logo image in the html email template ?
Comment #35
gregarios commentedYou can reference images from your website so it shows in the email if they allow remote images in their email client.
Comment #36
gregarios commented@quicksketch,
Will my HTML list work ever get into Webform, or am I just scurrying around wasting time on working out solutions?
I made an agreement with you in comment #11 that if I would port this capability then you'd include it, but after I made working versions for the 6.x-2.x and 6.x-3.x versions, you don't like the way I did it? You said the 5.x-2.x version is going away anyway. the I don't see any way I can help here further, and I'm quite disappointed. I guess will be sticking with my patched version of 2.9 for the foreseeable future I suppose...
Comment #37
quicksketchAs I said, if this isn't ported to the Drupal 5 version, this will not be included in the 2.x branch at all. In addition (just to make things crazy) the Drupal 7 port is also now available, meaning we need to port this across FOUR versions of Webform across three different Drupal versions. Clearly that's not sustainable. So I'm pretty sure this is going to be 3.x only. I'm caught up with more pressing data-integrity features/bugs at the moment, but I'll review this when I have time.
At a quick glace, I can say a few things need cleanup:
- Follow coding standards. The first IF statement in your patch needs to be separated into individual lines.
- This kind of templating is not acceptable, it should be automatic based on the e-mail style:
- Template style should be specified per-email, not site-wide (though a site-wide default like you have currently is a good idea).
Comment #38
quicksketchOh, seems I already reviewed this once in #23. See those comments too. :P
Comment #39
gregarios commentedIn Comment #10, I submitted a complete patch for 6.x-2.x.
In comment #11
So, I did a lot of work and discovered I couldn't port it to 5.x-2.x, so I gave up. THEN,
In comment #21:
So, then I ported it to 6.x-3.x in anticipation you would include it, since I'd already submitted the 6.x-2.x version. See comment #22. THEN,
In comment #37
??!! Can you see why I'm frustrated?
Comment #40
quicksketchI said:
In response to you saying:
Which I assumed meant that you only needed it for 3.x and not at all for 2.x. I haven't changed my mind on the fact that 2.x is maintained in-sync between versions. Basically I meant if you want this in 3.x only, there's no need for a Drupal 5 version, since 3.x doesn't exist for Drupal 5 (but does exist for Drupal 7).
Comment #41
gregarios commentedI see... so, you're saying I need to port it to Drupal 7 version now instead of Drupal 5? I could deal with this being for 3.x only I suppose...
Comment #42
quicksketchThe more important thing is addressing the issues I laid out in #23 and #37. Usually I can apply a patch to both versions in same version Webform version number with little or no changes. I was only requiring a patches for multiple branches if you're asking for a feature in the 2.x version (which is feature-frozen and I don't want to spend additional time working on it). If working only in 3.x, just a single patch for either D6 or D7 will work and I'll handle the differences.
Comment #43
gregarios commentedOk, I'll see what I can do about updating the patch soon for 6.x-3.x, fixing the issues. However, did you see my reason for not making the HTML option available on a per-webform stage, but globally? I think it is better to have it set globally, since there are no node-based HTML-or-plaintext solutions out there anyway. (And there shouldn't be IMHO)
I can fix the issue in #37, but the other issues I cannot... will this be a problem?
Comment #44
quicksketchI would strongly prefer the option of HTML e-mails to per webform, using the site-wide setting as a default.
Comment #45
gregarios commentedHow would you make one form send HTML while others don't? I'm completely confused on that point.
Comment #46
quicksketchIt's more a matter of user preference than a form-by-form basis. Making it per-email means that certain users could get a plain text e-mail versus an HTML one. It's commonplace on any mailing list to be able to choose if you want your e-mails in HTML or plain text, I personally always opt for plain text when given the choice. I think I made it pretty clear what I envisioned way back in #1, it's just a checkbox when configuring the e-mail.
Comment #47
gregarios commentedYes, but, you really need to look into how Mime Mail module works. The Mime Mail module is what determines if the emails are HTML or plaintext for each user. What I've been saying all along -- it doesn't matter if you send plaintext or HTML output to Mime Mail. IF the recipient has specified "plain text" in Mime Mail, they'll get plain text even if the output of your form is HTML! It is pointless to try and send plaintext on a per-email basis in your module, when the Mime Mail module is what determines if it is plaintext or not, even if it is HTML.
However, the reverse is not true. Mime Mail module cannot build HTML from plaintext, only plaintext from HTML. So, if you send out plaintext, Mime Mail cannot show it correctly for HTML users in the output of its emails. But, if you send it HTML for all your output, Mime Mail can send plaintext OR HTML depending on the user preference. (EVEN BOTH!)
If you would make Mime Mail (or any other HTML email mod module) a dependency, then you could just output HTML for all your emails and never worry about the plaintext side at all. :-)
Comment #48
gregarios commentedThis is the assumption you are making which is totally incorrect. Mime Mail will handle this for you.
Comment #49
Mac Clemmens commentedI tested the patch about a month ago and it worked great. I am also using the Mime mail module, and it passed through perfectly. I recently upgraded, so I'll need to re-apply and test the patch again.
Comment #50
gregarios commentedUnfortunately, I can't keep reworking the patch to fit every new release that Webform comes out with. If this will never get included in the module, which it looks like it won't, I'm too discouraged to continue. Maybe someone else can explain my position to the maintainers better than I can, and why my patch is a useful feature WITHOUT having to make it on a "per-form" basis, and pick up my (endless) patching in the future...
Comment #51
healthent commentedI do not understand either of you but here's what I think is happening:
gregarious, you want Webforms to pass the email through another module to turn it into plaintext. Thus, all email Webforms sends out is in HTML as a matter of course.
Advantages:
All forms automatically send out HTML email, if you have hundreds of forms you do not need to go into each specifically to set it to HTML.
Plaintext and HTML for all users.
Disadvantages:
Dependancy on another module, therefore dependancy on someone elses code, therefore learning about someone elses system.
Extra processing on the server.
Plaintext and HTML for all users is frankly not important in the modern web climate.
quicksketch, you want Webforms to build and send out HTML directly, and to send out plaintext directly. You do not want the email received by users to be both plaintext and HTML. You want the option to set within the webform whether to send HTML or plaintext.
Advantages:
No external module dependancy.
Less processing on the server.
Disadvantages:
Users that can only accept plaintext email are shit out of luck if the form is set to HTML email.
Need to manually set each and every single webform to the email style you want, a problem if you have already built many forms.
From my point of view, you are both right. Go with gregarious' method and you end up relying on an external module. Go with quicksketches method and you end up doubling up functionality that has already been coded. I personally would prefer the checkbox option in quicksketches mockup but both acheive the same result. I think it's fair to say that maybe quicksketch could let this one slide just maybe because someone else has already done the patch? If quicksketch doesn't like it he can change it to his preferred method at a later date, but in the meantime users would have access to HTML email! I mean it is all about the user experience right, not to step on any developer toes (look I'm sorry if I'm being rude I know it's your project and your decision quicksketch I'm just putting it out there).
Comment #52
gregarios commentedThis is what neither of you seem to understand... the Mime Mail module doesn't need any special compatibility or anything... it is a site-wide HTML email enabler. It makes changes to allow all emails to be received from the site in either HTML or Plain-text, on a per-user basis, selectable from a user's profile page, NO MATTER what module is sending the emails. It takes care of the whole thing! :-)
Almost all other modules allow you to fully set up templates that you can make fully HTML or Plaintext, and therefore set up your whole site with HTML or Plaintext emails through Mime Mail. So, if you design your templates with HTML, then Mime Mail can automatically strip out HTML for its plaintext users, and leave it in for HTML users.
Simplenews, Notifications, Subscriptions, and about 50 other email-sending modules all allow this functionality because they allow FULL HTML output to be configured through their built-in templating systems. Webform is the only one I've found that doesn't, so I made the patch to allow it. The way I patched it is the only way it can be done without a complete rewrite of the way Webform handles its "list-making" functions.
I think this is just way to simple for you guys to grasp... aside from implementing my patch, the ONLY thing that would need to be done to the Webform module is adding the dependency in the documentation for when people want HTML output to work right. The module will even work without it with my patch implemented.
You can do this already using the Mime Mail module — there is no need to reinvent this wheel like this. And, I don't mean "developers" can do this... the end-user or site admin can do this just by installing the Mime Mail module.
No, actually they don't. The whole reason I did the patches to begin with was because Webform wasn't outputting HTML format in the actual content of the
%webform_mail_fieldsvariable for its template. In the revised "HTML Template" version from comment #1 of this thread, the main content variable%email_valuesis still not outputting an HTML list. My solution enables the main content to be output as a true HTML list that can be styled in CSS. Yes, the Template can be formatted into HTML by the users in Webform's original and revised methods, but the actual content of the variables cannot unless my patch is implemented.Comment #53
healthent commentedOK.
So what you are saying is that the email template should be HTML code. Let's say for example, someone uses CKEditor to create the email template. So the email that is sent from Webforms is pure HTML code.
Except the email isn't sent - MIME module intercepts the output, keeps a copy of the HTML code, converts it into plaintext, and sends it as an HTML enabled email that will display plaintext for the email clients that do not have HTML email enabled. Correct?
And what you are saying is the form field values which Webforms passes into the email template via a token are plain text. So above and below those values you will have HTML code but the values themselves will be plaintext, presumably missing paragraph tags, line breaks etc etc. Right?
So your patch ensures that the form field values are "HTMLified" and the email template is capable of outputting HTML code as the email, and MIME module does the heavy lifting to turn it into the appropriate email.
It seems to me this is what quicksketch wants to happen as well - except for relying on MIME module. In his solution, unless I'm mistaken, those fields are also outputted in HTML - after all, he creates a HTML webpage to display the results of the submission. I think he wants that page to be used as the email template. In addition to this, he wants the option for there to be no HTML version of the outputted email if he wants. From the sounds of it, MIME module creates the HTML/Plaintext email no matter what and that may be behaviour he is not happy with. To be specific, even if a client is set to only display plaintext email, they still receive the HTML portion of the email. He wants either plaintext OR HTML, not both in one. I think.
Now I'm not a developer and I'm definately not quicksketch and this is his project to develop however makes him happy. But I can understand why he would not want to introduce a dependancy on another module for this functionality. On the same note, webforms is already dependant on some other modules such as "Select or other..." and "Webform Validation".
Frankly I think you have made an intelligent method, and I would deeply love to see it committed "in the meantime" while quicksketch works on his own preferred way. Having it in there wouldn't hurt and he can replace it once he gets time to implement his preferred solution. It would be nice if quicksketch could confirm whether he would commit this code if the errors he has pointed out in previous comments are corrected, but again this is his personal project, his hobby so it's all his choice.
Comment #54
gregarios commentedYes! Correct. Webform can allow people to make plaintext templates all they like, and still use Webform as an all-plaintext output emailer if people like, and the dependency is optional. However, if people want to make a fully HTML template, they'll need Mime Mail and my patch. (Because Webform won't output HTML content without my patch) :-)
Exactly. My patch inserts HTML tags in the appropriate places in the Webform module to allow the HTML list format, and I've even made a setting the admin can use to turn off the HTML changes my patch makes altogether.
Yes. In fact, even with my patch enabled so the Webform produces clean HTML style output, Mime Mail module can allow the end user to specifically set whether they wish to receive HTML, plain-text, or both, from the website as a whole.
My patch has a setting to allow the admin to turn off the HTML-ized output to allow the original plain-text output through, so this is not an issue.
This can never happen, though! The HTML Webform module would output as a web page can't fit in most email client windows, nor are a lot of HTML allowed in emails yet. You can't have Javascript, nor Flash in emails, and you must have absolute URLs, and all kinds of other things. This would also destroy any chance of the end user being able to style their output in the emails using CSS in the template. It just won't work, from a web designer point of view.
I don't know why... I don't know one other module that doesn't require an outside email system to get HTML emails out, since Drupal core doesn't have the functionality. If you can name one, I'd be surprised. I'd argue that the standard for HTML output in Drupal is Mime Mail, with over 15,273 sites using it as an installed base.
Comment #55
healthent commentedQuicksketch, do you mind posting a comment so gregarious know's which way to go?
Comment #56
wiredescape commentedsubscribe
Comment #57
adrianmak commentedI'm using 3.0 beta5 but I cannot see any email template on the webform interface.
Comment #58
gregarios commentedPlease open a new issue for that.
Comment #59
gregarios commentedComment #60
gregarios commentedAttached is a patch enabling HTML output functionality for Webform 6.x-2.10 (See comment #10 for further details) in case anyone is interested.
1) Place the patch in your uncompressed "webform" folder.
2) Navigate into the "webform" folder in your terminal or command-line window.
3) Run the following command:
patch -p0 < webform_2.10_html_patch_20100814.patchComment #61
quicksketchOkay well here's my up-front apology: @gregarios I've reviewed your patch several times and I'm not satisfied with the implementation. With all the back and forth we both had priorities and ideas about how it should be done. I wasn't happy with the approach you took and so I've completely rewritten the whole thing. I'm sorry (really) that you spent a lot of time putting this together but I won't be using what you've written for the project. I hope this hasn't completely put you off of contributing code to existing modules.
Here's my rewrite so far that includes what I consider to be important:
It does not include important features that should be added:
I'm thinking that on the admin/settings/webform page we should add something like the following:
Sending all e-mails in the default format would remove the options for HTML from the e-mail configuration form. Obviously none of these options would be shown unless Mime Mail was installed.
This patch also makes the start of supporting attachments, since it seems like a trivial addition. All that's missing is a loop through the submission to find the file paths that will be added as attachments. Attachments are also configured per e-mail.
Comment #62
gregarios commentedIs that a patch for 6.x-3.1?
Comment #63
quicksketchIt's for the 6.x-3.x dev version (against the DRUPAL-6--3 branch) it should apply to 3.1 I think. I'll port it to Drupal 7 once we finish the coding.
This update includes functionality for including attachments in e-mails.
Comment #64
quicksketchMarked #159678: Send file attachments in email duplicate.
Comment #65
gregarios commentedThe patch in comment #63 seems to work for HTML email in general. I can use the HTML functionality you've done. Thanks for developing this.
However, I get an
Invalid argument supplied for foreach() in /usr/local/apache2/mysite.net/htdocs/sites/all/modules/mimemail/mimemail.inc on line 334error and no attachments are attached when I try to use the email attachment feature.Comment #66
stella commentedpatch reroll against 3.2
Comment #67
quicksketchThanks @stella and @gregarios for your feedback. Updated patch to fix the foreach() error noted in #65 and added the options for "E-mail format" and "Override default format" to the Webform settings page. I think this is all the functionality needed, though it could use additional testing.
Comment #68
quicksketchMinor update removing an unnecessary check.
Comment #69
quicksketchI ran into a bug with MIME Mail while testing this patch. It would probably be good to get it corrected in MIME Mail before adding this to Webform. See #897346: Plain text e-mails with attachments get sent as HTML
Here's another minor update that includes our new variables in hook_uninstall().
Comment #70
quicksketchTurns out the bug I had was present only in the 6--1 branch, not in HEAD where current development is. Drupal 7 port attached, though it doesn't do anything visible since MIME Mail does not exist for Drupal 7.
Comment #71
quicksketchI've committed these patches to ease porting/patching of #248157: Allow any Webform to be displayed as a block. Please post any problems with the dev version here or open a new issue.
Comment #72
samdds commentedI'm using webform 6x3.2
Is it possible to strip the %email_values and send the email as HTML now?
Do I have to apply a patch? Could you please explain it a bit?
Comment #73
quicksketchClick "view all releases" on the project page, then find the 6.x-3.x-dev version. I don't post dev releases on the project page because I prefer people to use the official releases when posting bug reports. This feature will be in the 3.3 version of Webform.
Comment #74
sgabe commentedI took a look at this now. As I see it isn't part of 3.2.
The list parameter won't be needed in the upcoming releases of Mime Mail, see #629038: Attachements dont respect ‘list’ setting.. However this will work for now and can be postponed until a new release, or left as it is though will be unnecessary.
We should use a more descriptive mailkey like "webform-$nid" in order to support features like #882528: Template suggestions based on mailkey, so the messages would be able to have their own .css and .tpl files.
Comment #75
quicksketch@sgabe I think these issues may need further discussion than immediately making the changes, could you open new issues?
Comment #76
agogo commentedTHANK YOU for the Mime support! It saved my life. Kudos!
Comment #78
brei9000 commentedHas this been added to 6.3? I couldn't get the patch to work. The checkbox wouldn't stay checked when submitting the form.
Comment #79
gregarios commentedI just wanted to say Thank You, quicksketch, for taking my feedback, and implementing HTML output in the 3.x version very well. I've converted my CSSs in my Mime Mail template and it is working very well with the Webform 6.x-3.4 version. Thank you again for the work on this.