I don't know if this belongs in Rules support, or where else??? I'm using Rules to email a copy of the node when certain node types are created. I just use this:

<?php
print node_view($node); 
?>

to include it, as I don't know any other way to include the nodes or any special fields. Is there any documentation on this? If so, I haven't been able to find it anywhere. My problem is it doesn't implement any line breaks, so the entire node is squished together on one long wrapping line. Is there any good way to force natural line breaks, for instance at the end of each cck field, or after a div, or...?

It also lists at the end of the node:
[1] url of node
[2] url to user/author

Is there a way to format or change the 1 and 2 to something more user friendly, like "read this online here" and "submitted by this user"?

Comments

cindyr’s picture

I found this: http://drupal.org/node/298708

The patch works and allows the body to have line breaks after it, but the CCK fields still don't. Any ideas?

fago’s picture

Status: Active » Fixed

I've just removed the call to drupal_html_to_text() for now. -> Updated to next dev snapshot and try again.

Christopher Herberte’s picture

fago, is the removal of drupal_html_to_text() likely to be permanent?

cindyr #1
Try mimemail module using action: Execute custom PHP code. Tested this with good results.

mimemail(
  'info@example.com', 
  'you@example.com', 
  'Title: '. $node->title,
  node_view($node), 
  $plaintext = NULL, 
  $headers = array(), 
  $text = NULL, 
  $attachments = array(),
  $mailkey = ''
);

cindyr’s picture

I'm using Drupal 6.x. Do you know if the development snapshot of Mimemail works for 6.x?

Thanks for the suggestion.

Christopher Herberte’s picture

My tests were on 6.x with the latest dev snapshots of Mimemail (Sep-21) and Rules (Oct-3) -- also installed were the ususal, cck, views, etc. as there were reports of misbehavior but I had no such problem. I am now using this combo on a production site. Eeechhh!

HTML in e-mail imho is probably a better solution for emailing cck / node content second to the pure text option but it's broken :(

Maybe Rules needs to have it's own mail preparation function/s.

fago’s picture

hm, or mimemail could provide an appropriate action for rules

Christopher Herberte’s picture

Version: 6.x-1.0-beta2 » 6.x-1.x-dev
Status: Fixed » Active

That would be nice, don't know about the chances of that happening real soon.
Do you have any objections to a "Send in HTML" option (admin or action?) w/ a hook_mail_alter() for htmlizing?

fago’s picture

no, as long as the code is simple and so easy to maintain.. :)
If it's not, I prefer to have this only in a separate module.

mitchell’s picture

Title: formatting rules emails » Investigate html formatting features
Component: Rules Engine » Provided module integration
Category: support » feature

@Rules developers: Would you like to integrate Mime Mail for the email action?

Do you have any objections to a "Send in HTML" option (admin or action?) w/ a hook_mail_alter() for htmlizing?

@Chris Herberte: If you already have this figured out, this would make for a good documentation page. Since the handbook is broken, I would suggest using this issue to start with.

mmilo’s picture

I'm a bit confused. Does this mean that we *can't* use any HTML formatting features as-is at the moment?

II'm using PHP code to develop an e-mail, but I can't seem to create any line breaks. This includes using drupal_html_to_text("<br />"); to try and do so.

liquidcms’s picture

subscribing... mostly...

not sure if this is same topic of of any use.. but i use "send tokenized email" and it doesnt add LF's.. don't get me wrong.. i LOVE Drupal.. :).. it paid for my shiny new sports car.. and is paying for my house.. but boy.. it sure sucks at email!!

in the past i have always had to add phpmailer to get smpt auth so i could go through my isp's mail server for my devel setup, i would then hack phpmailer to and add this:

  //clean up our email a bit by filtering for CR and URLs
  $mailer->Body = _filter_autop(_filter_url($mailer->Body,0));

to use drupal's build in url/CR filters to do the right thing for emails.. not sure if that helps here, maybe just adding mimemail does the trick (although last i checked it didnt play nice with smtp auth)

liquidcms’s picture

yea, from initial post here:

It also lists at the end of the node:
[1] url of node
[2] url to user/author

what the hell's that?? lol.. been trying to sort out where that is coming from; thought it was some odd thing my isp mail server was doing. actions didn't use to do that so didn't think it was from rules module.

why can't i add url's in my email; even plain text emails can handle that.

i just added htmlemail module and it lokos like things are a bit better; some CR's likely could get it to work but still need to stop the silly url pulling thing and tacking at end of email.. that makes this pretty much useless as it is.

liquidcms’s picture

yay.. fixed...

perhaps what's being discussed above, but took less to time to find and hack than to post here.. i am not one to prefer hacking a module; but not sure of any other way to fix this, anyway, i guess not rules that was doing this but token.module

i made this mod in token_actions.module at line 139:

//$params['body'] = drupal_html_to_text(token_replace_multiple($context['message'], $context));
$params['body'] = token_replace_multiple($context['message'], $context);

and i now have perfect email.. finally.. :)

mitchell’s picture

Title: Investigate html formatting features » Fix token html formatting features
Category: feature » bug
Status: Active » Needs work

@liquidcms: This is a fix for token_actions? I ask because the rules documentation advises not to enable token_actions.

I think token_actions out of place at the moment and it's worth reconsidering whether it should be a part of token module, a separate module, or exist in rule's module integration. I'm not sure how I want to proceed with that, but this issue would probably help in figuring that out.

fago’s picture

Title: Fix token html formatting features » Investigate html formatting features
Category: bug » feature

Support for token_actions actions has been dropped - there are better equivalent actions shipping with rules, so rules hides the others now.

@mime-mail:
Support for mime-mails makes definitely sense. If easy enough, we could just add an option to the send mail action. If the code becomes more complex, I'd prefer an extra action, ideally shipping with the mime-mail module.

@HTML:
We could also add an option, that says "treat text as HTML" or so, which means it uses the function again and converts the html to text.

mitchell’s picture

Marked #195584: HTML formatting in message? as a duplicate of this issue.

fago’s picture

patch adding mime-mail actions in #501722: HTML mail actions for Rules

Aren Cambre’s picture

mitchell’s picture

Status: Needs work » Closed (duplicate)

Marking as duplicate of #501722: HTML mail actions for Rules.

As a bonus, that issue is marked as 'needs review' :)

mitchell’s picture

Component: Provided module integration » Provided Module Integrations

Updated component.