Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#6 | workflow_ng_system.inc_mime_mail.patch | 1 KB | jbomb |
#6 | workflow_ng_system_forms.inc_mime_mail.patch | 1.52 KB | jbomb |
Comments
Comment #1
jereme.guenther CreditAttribution: jereme.guenther commentedI 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".
Comment #2
fagoindeed, 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!
Comment #3
jereme.guenther CreditAttribution: jereme.guenther commentedI 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?
Comment #4
fago-> 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.
Comment #5
j0rd CreditAttribution: j0rd commentedHas this feature been implemented in the latest workflow-ng?
I need to be able to send HTML emails.
Comment #6
jbomb CreditAttribution: jbomb commentedThe 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.
Comment #7
jbomb CreditAttribution: jbomb commentedComment #8
fagothanks.. 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(..);
Comment #9
j0rd CreditAttribution: j0rd commentedset 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.
Comment #10
jbomb CreditAttribution: jbomb commented@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 :
with
per your suggestion.