I would be really nice to have an option when sending emails to specify if the email is plain text or html. It would be even better if this could be decided by some cck field (perhaps a checkbox with 0 and 1 as values?).

I have hacked together a fix for myself just setting all the emails to HTML since I don't currently need plain text ones, however the feature would be handy.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jereme.guenther’s picture

I guess it would be nice to display my hack for others in case they want to implement it before it becomes part of the project:

In file:
workflow_ng_actions.inc
On line:
258
Is a function called:
function workflow_ng_action_mail_to_user($user, $settings, &$arguments, &$log)

In that function is this line:
if (drupal_mail('workflow_ng_action_mail', $to, $subject, $message, $from)) {
replace it with:
$headers = array(
'MIME-Version' => '1.0',
'Content-Type' => 'text/html; charset=UTF-8; format=flowed',
'Content-Transfer-Encoding' => '8Bit',
'X-Mailer' => 'Drupal'
);
if (drupal_mail('workflow_ng_action_mail', $to, $subject, $message, $from, $headers)) {

----
I am not sure how accurate all the settings are, but the sent emails ended up as html so it seems to have worked. If anyone sees errors in the $headers array please point them out, I copied it almost directly from Drupals documentation; I just changed "text/plain" to "text/html".

fago’s picture

indeed, this would be a great feature. It would be cool if you could provide it as patch, so that one can optionally select to send it as HTML!

jereme.guenther’s picture

I would if I could, but I am new to Drupal and all the software and methods they use.

I don't know how to make a patch for it. It looks like I would use some sort of CVS software. Do you know of a good version for Ubuntu Linux?

fago’s picture

-> http://drupal.org/patch

in ubuntu the easiest way to create a patch is probably to use the "diff" tool -> apt-get install diff
then just make a diff between the latest workflow-ng snapshot and your modified version, the output is the patch

CVS can be used too for creating patches, it's more convenient if you are creating patches frequently.

j0rd’s picture

Component: Code » Miscellaneous

Has this feature been implemented in the latest workflow-ng?

I need to be able to send HTML emails.

jbomb’s picture

The following patches add a select box for email format on the workflow "send an email to an arbitrary address" and "send an email to a user" configuration pages. This allows an administrator to send an email in either text/plain or text/html formats.

The patch was originally rolled against the 5.x-2.1, but I've been able to apply it to both 5.x-2.1 and 5.x-2-dev.

jbomb’s picture

Version: 5.x-1.0-beta5 » 5.x-2.x-dev
Status: Active » Needs review
fago’s picture

thanks.. please watch out for tabs in your code - only use spaces for indentation. Also you shouldn't pass the mime setting through token, as one can't use tokens there. Use return array('mime' => value) + workflow_ng_token_get_settings(..);

j0rd’s picture

set expandtab for vim ... if you happen to use it. Set tabstop=N and set shiftwitdth=N are two other commands you can look at as well. http://wiki.linuxquestions.org/wiki/Vim

I'm looking to use this as well, so I think I might merge the patch into my code. I'll let you know if I run into issues.

Thanks jbomb.

jbomb’s picture

@j0rd how is this working out for you? any trouble? I've been using it on one of my sites with no problems.

@fago If you're interested in adding this functionality I can re-roll this against the current dev snapshot and remove replace the tabs with spaces and the following line :

return workflow_ng_token_get_settings(array('mime', 'from', 'subject', 'message'), $form_values);

with

return array('mime' => $form_values['mime']) + workflow_ng_token_get_settings(array('from', 'subject', 'message'), $form_values);

per your suggestion.