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.
Yesterday I felt like "whatever, I'm not going to be productive today anymore so let's create some Rules actions for Mime Mail instead", and alas, attached to this issue you can find those. Straight port of Rules' own text mail actions with a few Mime Mail specific extras, so the copyright for these files is with me and fago.
Comment | File | Size | Author |
---|---|---|---|
#104 | 01.png | 307.31 KB | narcisgirona |
#102 | Screen shot 2012-02-23 at 10.59.12.png | 20.05 KB | narcisgirona |
#87 | screenshot-email.png | 14.91 KB | jday |
#84 | mimemail.501722_03.patch | 10.24 KB | sgabe |
#59 | mimemail_rules_59.patch | 9.9 KB | criz |
Comments
Comment #1
crizAwesome, this rocks! Sending HTML mails with rules is highly required. Many thanks! Have I already said that we'll miss you Jakob? ;)
Will test it and report back...
Comment #2
crizPatch applied nicely. Tested functionality with a custom rule: HTML mail got sent out as expected, attachements are working great too. :)
Comment #3
crizSmall addon: Inserting tokens and php variables is not working with this patch...
Comment #4
jpetso CreditAttribution: jpetso commentedI feared this would be the case, with the storage not being simple strings anymore. I might go researching how Rules accomplishes this, and whether it's necessary to go back to string storage instead of prepared arrays.
Comment #5
fagooh nice, this feature was already often requested by rules-users.
@input evaluators: I think you simply forgot to add some settings to the 'input eval' properties, e.g. 'message_html' is not in there.
Also I'd suggest to the doxygen
in the beginning and
in the end. So the functions appear in the rules integration docgroup.
Comment #6
fagoah, and does mimemail remove "\r" and "\n"? As the patch does it only on configuration time, but this wouldn't apply to tokens.
Comment #7
aantonop CreditAttribution: aantonop commentedTo fix the token issue mentioned above and implement fago's suggestion and doxygen marks, try this additional path (on top of the one above).
It tells rules to evaluate the message_html and message_plaintext variables to replace tokens. It adds doxygen marks (hope I did it right).
With these changes, HTML email works, tokens get replaced!
Comment #8
jpetso CreditAttribution: jpetso commented(separating tags by commas, not spaces)
Comment #9
StephenFresh CreditAttribution: StephenFresh commentedSorry for this noob question - but what file is this patching is this a new file to go in the rules module - module directory called mimemail.rules.inc. (Because I dont have this file in rules or mimemail module)
What am I missing I understand comment #7's adjustment to the initial attachment just dont know what the original file is patching.
Any basic instructions appreciated
Comment #10
criz@StephenFresh
The original patch is adding new files to the mimemail module. Just run it in the mimemail module root directory. Patch in #7 is only adressing changes for fixing the token issue...
Comment #11
StephenFresh CreditAttribution: StephenFresh commentedThanks Criz for the help did that and it created the two extra files - added those to the module and it appears to work.
Though i hit another issue I'm running a patched version of smtp ( http://drupal.org/node/132903 ) to work with mimemail which works well btw.
The problem is I get this error when triggering the html email sending rule (Send an HTML mail to an arbitrary mail address) in question:
"The submitted from address () is not valid."
normal from email address prompts this error also left blank to use the sites email prompts the same error
Any tips on adjusting the above patch/es so that the from address is being passed to smtp module correctly?
Comment #12
crizThe patch from #7 is not working with recipients. Code in mimemail_rules_action_mail_submit() is responsible for that. Don't know if mimemail is removing "\r" and "\n", seems not.
Successfully added support for cc and bcc recipients btw. If this above mentioned problem is solved I will post a patch...
Comment #13
fagoah, sry I've missed something. The token replacements only work as long as the setting stays as "string", thus transforming it into an array has to happen at action runtime - after the token evaluation.
Comment #14
crizso, here is a full patch with working token and php variables and cc/bcc recipient fields for the "send mail to an arbitrary mail address" actions...
Comment #15
StephenFresh CreditAttribution: StephenFresh commentedI tried this patch #14 - but i still get same problem - as #11 - I'm sure it would work if i didnt have smtp in the process and there in lies my problem.
Comment #16
seren10pity CreditAttribution: seren10pity commentedI tried this patch #14, and... thank you very mutch !
I would just notice that, (maybe it's only for my case) php is well interpretated in the recipient address field, but not in body.
Then, it seems that it doesn't use the same template than the original 'sent mail to an arbitrary e-mail adress' because using the same code, I get a buggy mail...
But guys, if you didn't post these patches, i would have been in the mess... So A big Thanks to you !
Comment #17
criz@seren10pity
What exactly is buggy in the mail?
Php is working great for me in mail body, but have tested it only with "send mail to an arbitrary e-mail adress" action.
But I've noticed some issues with php in bc and bcc fields...
Comment #18
fago@mimemail_rules_action_mail_to_user_submit:
As I said in #14 this processing of strings needs to happen on-execution time as then the tokens/input evaluators got applied! Once they have been applied on the strings, you can process them.
Comment #19
crizOkay, here is the patch from #14 with some changes:
-- string validation only on execution time
-- some further small improvements suggested by fago
Tested it heavy on 2 different Drupal Installations and it works fine. Also tested and validated with coder module...
Comment #20
jvieille CreditAttribution: jvieille commentedIt works very well.
How can we customise the default presentation?
Comment #21
fagoI did another code-review:
* imho $settings['bc'] should be $settings['bcc'] - why bc!?!?
* settings validation: Imho the function is misnamed, currently it does setting processing but this is no validation and is quickly confused with form validation.
+ //if $user is empty set acting user
+ if (empty($user)) {
+ global $user;
+ }
This is quite confusing as never mail is going to be sent to the active user that way. I think it woould make more sense to leave $user unset when we are sending to $settings['to']. But that's probably minor.
Comment #22
guysaban CreditAttribution: guysaban commentedThanks for this very useful module and patch. I've been testing the HTML email formatting.
There is also a problem when when using
<a href="mailto...">
in the HTML body of an email send from Rules in HTML markup. Spaces are added to the HTML markup which can break<A>
links in the text. It seems to be a bug but I don't know where.Example Body:
<a href="mailto:test@tutttestmail.com?subject=Subject's Text&body=Dear User%0AIt's good to here from you.>send email</a>
Where %0A is HEX for a new line, but this does not work in the resultant email text. No new line is added. When I view the source markup in the email client (outlook) %0A is replaced with a new line but it needs to remain %0A in the source for the mailto to have a newline in the resultant email. I am not sure if this is a mail client issue - its seems not since the source markup has a new line thus it received the source without the %0A. The source email is recieved with %20 which is the HEX for spaces ' '.
ALSO, When using an apostrophe, as in ', in the text or title a / is added before the apostrophe (/') in the subject and body of the sent email text.
ALSO, found issue with using multiple
for some reason they have spaces added to them. I am not sure is this is due to the same issue mentioned a few lines above.Comment #23
scottrigbygreat work jpetso, criz, & fago - I'm looking forward to testing this out ;)
Comment #24
tomski CreditAttribution: tomski commentedThanks for these useful rules.
I have problems with token replacements. They work with normal "system email" but not with mimemail rules (the list of replacement available appear as normal but the email just show the [not replaced]).
I use the last dev of token module and last rules module, and I have applied patch 19.
Any help would be appreciated (question for the other users : did you make it work with token replacements?).
Thanks!
Tomski
Comment #25
crizHi, did you use the patch from #19? Which rules action did you use?
criz
Comment #26
tomski CreditAttribution: tomski commentedThat was a very quick answer! In fact it was patch 19 (I have just edited the comment #24).I have tried both "to arbitrary address" and to "user " with no success.
Since I was not sure about which patch I have applied I re-applied and re-install it on the drupal site. The old action still does not work even after updating it, but any new action created now it works. Sorry about having posted an issue without double-checking before if I had gone through all the suggested steps to solve the problem (I am quite sure it was the patch #19 but not 100% since I have applied more than one week ago).
Thanks in any case!
Tomski
Comment #27
crizHmmm, I've not tested this with current token dev and rules 1.1 so far. Does it work with a standard rules action? Do php variables work?
Maybe you face a simular issue to http://drupal.org/node/432518
Okay, so it works now. Great... :)
Comment #28
locomo CreditAttribution: locomo commentedthis was pretty much working great for me except for one thing.. in the plaintext version of multipart emails all of my carriage returns are getting stripped out
i notice on line 135 of mimemail.rules.inc
when i comment this out of course my carriage returns come back.. but i'm no expert at php and am not sure if its a problem to drop this line
thanks for this integration with rules!
Comment #29
jvieille CreditAttribution: jvieille commentedThis works well when insreting html in the message box in Rules
However, token replacement of HTML content only displays the corresponding HTML code, but does not not render it.
(in other words, if the node content is plain text, it works OK, but if it is rich HTML text, that does not work...)
Comment #30
chaumurky CreditAttribution: chaumurky commentedAfter a recent core upgrade (6.12 -> 6.14) I now see this error editing existing page "Send an HTML mail to an arbitrary mail address":
warning: preg_match() expects parameter 2 to be string, array given in /var/www/.../includes/bootstrap.inc on line 777.
Should this be anything to worry about? What are the implications?
Comment #31
crizjvieille, do you have used the raw tokens? Just wondering, because rendering html token works for me...
Comment #32
EvanDonovan CreditAttribution: EvanDonovan commentedSubscribing. I plan to test this in the next few days.
Comment #33
BenK CreditAttribution: BenK commentedSubscribing too...
Comment #34
jferjan CreditAttribution: jferjan commentedsubscribing
Comment #35
EvanDonovan CreditAttribution: EvanDonovan commentedForgot to mention - I tested the patch from #19 and it is working excellently, although I had to manually apply it. It was a while ago now, but I think what happened was that it created the includes in the wrong subdirectory.
Comment #36
nickgs CreditAttribution: nickgs commentedI have tested the patch from #19... works great!
I am using tokens extensively in my emails. The HTML is being attached to the emails, is this the desired functionality? I think it would be nice to have the HTML message embedded in the body of the email.
Thanks.
Nick
Comment #37
wisniewski CreditAttribution: wisniewski commentedThis path is great, and will be even more powerful with some nice features:
- support HTML Mail Template (/admin/settings/htmlmail/template)
- support Input Filter (eg. Full HTML)
Now I add files through PHP code - load node with attached files and copy proper MIME and file location, this is quite simple and I wonder how to make it even simpler.
Regards
Kristof
Comment #38
geerlingguy CreditAttribution: geerlingguy commentedSubscribe.
Comment #39
tobiberlinsubscribing
Comment #40
Aren Cambre CreditAttribution: Aren Cambre commented#114699: Diff module should support Token is related to this.
Comment #41
TripleEmcoder CreditAttribution: TripleEmcoder commentedSubscribing.
Comment #42
wisniewski CreditAttribution: wisniewski commentedIt does not work with patch:
http://drupal.org/node/358439#comment-1426276
and sends attachements only with the first mail in Rule Set.
Comment #43
criz@infotrendy
Please provide some more info. Attachements in rulesets are only working once? Is there always the same file attached?
http://drupal.org/node/723072#comment-2641530 is working now?
Comment #44
wisniewski CreditAttribution: wisniewski commentedIt was the problem described here:
http://drupal.org/node/358439#comment-1426276
So only the first mail in Rule Set (or just first execution of mimemail()) is send with attachments - I used the same files every time.
The problem in #42 was due to overpatching mimemail with more patches, now I use combination of
http://drupal.org/node/501722#comment-1925296
http://drupal.org/node/358439#comment-1426276
on 6.x-1.0-alpha1
and works great with Rules, it would be good to include this in next release.
Comment #45
aaron CreditAttribution: aaron commenteddidn't see this issue earlier. there's also a patch for review at http://drupal.org/node/727210 adding rules + token support to mail logger.
Comment #46
sgabe CreditAttribution: sgabe commentedWith the Mime Mail template file the message will contain the
<html>
and<body>
tags twice. The default value of the HTML message should rather be empty. The attached patch is #19 with removed default value of the field in question.Aside from this, it looks fine.
Comment #47
mennonot CreditAttribution: mennonot commentedWhen I install the patch in #46, everything works as expected up to the point after I have created the "Send an HTML email to an arbitrary email address" DO section in the rule elements. The email is sent formatted in html with the tokens as expected (with the exception of node_body).
However, where I return to edit the fields in the "Send an HTML email to an arbitrary email address" section, the "Subject" and "HTML message" fields are blank, even though they obviously are saved in the database.
Comment #48
mayerwin CreditAttribution: mayerwin commentedWas this patch applied to the latest release?
Comment #49
sgabe CreditAttribution: sgabe commented@mayerwin: If you take a look at the patch, you will see that it creates 2 new files and doesn't modify anything. So the patch applies fine on any 6.x version.
Comment #50
jday CreditAttribution: jday commentedRE: #28 carriage returns get stripped out of the plain text version
is there a reason to change carriage returns into spaces? It's really hard to read the non-html version without line breaks, so I'm wondering if commenting out line 135 would have any negative consequences, seems like a good idea to me
Comment #51
criz@jday
yes this is a kind of issue actually. Have to find out if this str_replace is really necessary for security reasons...
Any ideas someone?
Comment #52
sgabe CreditAttribution: sgabe commentedChanging status.
Comment #53
UNarmed CreditAttribution: UNarmed commentedGreat going to give this a try now! =D
Comment #54
jday CreditAttribution: jday commentedhas anyone gotten the cc and bcc fields to work? when I have the cc field filled the value is displayed on the main recipient's email as getting cc'd but the email is not actually sent to the cc email in that field. And email addresses in the bc field also do not get the email.
Comment #55
criz@jday
this should be working. take in mind that some mail provider send a mail only once to an e-mail address, even if bc or cc. tried with a different e-mail addy?
Comment #56
EvanDonovan CreditAttribution: EvanDonovan commentedI think that the bcc works for our organization's implementation, but I would have to confirm with my coworkers to be 100% sure.
Comment #57
jday CreditAttribution: jday commentedthanks all for the replies!
I have set up different emails for each (recipient, cc, bcc) and it looks like the recipient and cc fields are working, so just the bcc is not working according to my tests. I went into mimemail.rules.inc and changed all instances of 'bc' to 'bcc' but there was no change in results so I changed it back.
Comment #58
PipB CreditAttribution: PipB commentedI've got a problem with installing Mimemail in Drupal 6.16 with rules, views, and a lot of other modules.
After installing I could not save a node that triggers the mail-action-rule and got a white webpage: error 500....
After that I found an advice on the forum about a module: htmlmail > (http://drupal.org/node/553466). I've installed it and it works perfect for appending new lines in de mail-body with "< br/ >".
Maybe easier for people who only wants a HTML message in the body-mail.
Comment #59
crizFinally I did a reroll of this patch based on #46.
- #50 no more stripping out /r and /n in mail body and mail body text, so the text version works fine with returns
- #21 variable settings['bc'] is now $settings['bcc']
- #21 renamed settings_validate to settings_process
- #21 leaving $user unset
Tested all three actions and all form fields (incl. bcc) successfully with rules 6.x-1.2 and mimemail HEAD.
Comment #60
vstmusic CreditAttribution: vstmusic commentedIt works, but the body of the email is strange. It includes the size and image of the body of the website. Is it possible to hide that ?
Comment #61
criz@vstmusic
this seems to be default mimemail behaviour.
Place a mail.css file in your theme base directory, then Mimemail includes that instead of all the CSS files of your default theme. http://drupal.org/node/614782
Comment #62
sgabe CreditAttribution: sgabe commented@vstmusic: About that see #685574: Optional site's css embedding.
Comment #63
vstmusic CreditAttribution: vstmusic commentedThere seems to have a bug : When I use the form created by your file "Send an HTML mail to a role" and I save it, the content of form (sender, message) is BLANK when I come back to the form (after saving) for example for editing the rule.
Do you understand my problem ?
Comment #64
sgabe CreditAttribution: sgabe commented@vstmusic: You are not the only one who is experiencing that, see #47. I think this still needs work then.
Comment #65
crizI can't reproduce this. Please add a new action and test it with this one. Thx.
criz
Comment #66
vstmusic CreditAttribution: vstmusic commentedHow can I "test" it ?
Comment #67
crizDo you have the latest rules module version 6.x-1.2?
Did you use the patch from #59?
Does the problem persist if you add a completely new rule/action?
Comment #68
vstmusic CreditAttribution: vstmusic commentedI confirm the bug ! with 6.x.1.2 and #59 and new rule =>Blank forms
Comment #69
sgabe CreditAttribution: sgabe commented@vstmusic: I can't reproduce it either. Can you give us step-by-step instructions? It's okay if the forms are blank when you add a new rule, see #46 above. The problem is if an existing rule's setting is vanishing... Is this what you experience?
Comment #70
vstmusic CreditAttribution: vstmusic commented1. I create a new rule with an action : "Send an HTML mail to a role".
2. I fill the subject field and the HTML message field.
3. I save the rule. (and I test that the message is correctly send)
4. When I want to edit my rule, I click again on my rule and on my action =>
5. Oh ! All is empty (invisible).
Do you understand ?
Comment #71
sgabe CreditAttribution: sgabe commented@vstmusic: I followed your instructions, but when I go back to edit the rule, the action fields are filled just as I saved them...
Comment #72
vstmusic CreditAttribution: vstmusic commentedstrange ! I don't understand....
Comment #73
Aren Cambre CreditAttribution: Aren Cambre commentedIsn't this going into 6.x?
Comment #74
sgabe CreditAttribution: sgabe commented@Aren Cambre: There is no available 6.x-1.x development branch right now. The action is in HEAD so patches should be made against that.
Comment #75
YK85 CreditAttribution: YK85 commentedsubscribing
Comment #76
corbacho CreditAttribution: corbacho commentedMy tests:
Mime Mail 6.x-1.0-alpha4 with patch #59
Rules 6.x-1.2
I tried also the steps of #70 and couldn't replicate error
And Bcc field is working for "Send an HTML mail to an arbitrary mail address"
So for me is working perfectly, these actions are very useful and will be great to have them in the module. It's by far the best alternative I found for automated notifications: Rules + Token + Mimemail rocks
Comment #77
crizUsing patch #59 also for a month now on various sites. Working great...
Comment #78
jvieille CreditAttribution: jvieille commentedI am still running 19 - perfect
Comment #79
Nathaniel CreditAttribution: Nathaniel commentedMime Mail 6.x-1.0-alpha4 - manually installed patch #59
Rules 6.x-1.2
Tested on two different websites. Works great!
Comment #80
chaumurky CreditAttribution: chaumurky commentedJust a quick one, when I run patch -b -p0 < mimemail_rules_59.patch I get the following:
Anyone had this? Any way around it?
Comment #81
sgabe CreditAttribution: sgabe commentedThanks for some changes in the past commits the patch could use some work:
Comment #82
twistedindustries CreditAttribution: twistedindustries commentedUsing 59, I am also experiencing the blank form glitch. The only thing that seems to stay is the
Recipient:
CC Recipient:
BCC Recipient:
fields, all else are always blank on edit.
Comment #83
twistedindustries CreditAttribution: twistedindustries commentedI switched to #19 and it seemed to help.
Comment #84
sgabe CreditAttribution: sgabe commentedAttaching a new patch according to #81. I see Rules uses verbose function names for actions, then we shall stick with that.
Comment #85
jday CreditAttribution: jday commentedjust upgraded to mimemail 6.x-1.0-alpha6
applied patch in #84
there's a problem now when using a rule to send html email:
the bcc field does not convert tokens or evaluate php
Comment #86
crizTested patch from #84 and it worked fine. No problems with evaluating php or form default values.
Comment #87
jday CreditAttribution: jday commentedI have a rule that sends an email to three different addresses:
To: emailA
CC: emailB
BCC: emailC
emailA and emailB are sent, and looking at the 'recent log entries' is this:
"Successfully sent HTML email to emailA, [node:field_emailC-raw], emailB"
If I switch it up so that emailB is the bcc and emailC is in the CC field, then emailA and emailC are sent but not B
log entry:
"Successfully sent HTML email to emailA, [node:field_emailB-raw], emailC"
the token value for the bcc was not getting converted to the actual value
FOLLOW UP
after deleting my rule and creating it from scratch, the bcc functions as expected. weird - but at least it's working now, whew
Comment #88
dontgoquietly CreditAttribution: dontgoquietly commentedHi, I have not been able to get this to work yet. I have tried putting the two patch files in the mimemail includes, in the rules modules subfolder, and in both cases ran update.php - but the form is not altered on the add a new action screen.
using
Mimemail 6.x-1.0-alpha6
Rules 6.x-1.2
is there something I'm missing? Do I need to write an include somewhere?
Comment #89
sgabe CreditAttribution: sgabe commentedThis is still a feature request.
Comment #90
YK85 CreditAttribution: YK85 commentedHi, I was wondering if there a newer patch that may be tested? Or the module+patch that the community may test?
Being able to send HTML emails via Rules would be great!
Comment #91
sgabe CreditAttribution: sgabe commented@dontgoquietly: You need to apply the patch in #84 to Mime Mail, see Applying patches for more information about how to do that.
@yaz085: Did you test the one in #84? What did you experience?
Comment #92
criz@jday
Do you have reconfigured your rules after applying the patch? Token and PHP evaluation seem to work for me.
Comment #93
sgabe CreditAttribution: sgabe commentedSince there isn't any new bug reported and the patch seems fine, I am marking this as RTBC. Please confirm or confute.
Comment #94
jvieille CreditAttribution: jvieille commentedFor me, it is ok since #19...
Waiting for the committ!
Comment #95
sgabe CreditAttribution: sgabe commentedPatch in #84 is committed to HEAD with minor changes (doxygen marks, etc). Thanks for the work, everyone!
Comment #96
butler360 CreditAttribution: butler360 commentedSo if I use a CCK field token for sender or recipient it should work, right? Because if I use a token in one of those fields I get this:
Please enter a valid e-mail address for recipient.
Comment #97
Aren Cambre CreditAttribution: Aren Cambre commentedComment #98
sgabe CreditAttribution: sgabe commentedMoved this new issue (#96) to #966514: Cannot use tokens for sender and recipient in Rules actions
Comment #99
zauravI tried #84 with 6.x-1.0-alpha6 and am getting the email ok, however the attachment isnt getting attached.
I'm trying to use "[node:field_pics-filefield-filemime]:[node:field_pics-filefield-filepath]" in the attachment field. I even replaced that with "image/png:sites/default/files/1.png" but to no avail.
Tokens in the HTML field are working fine.
I'm on Drupal 6.x-19
Edit: I'm sorry, the problem was I was including double quotes in the attachment field. That fixed it.
Comment #100
Offlein CreditAttribution: Offlein commentedSubscribing - And curious if this will support Input Formats / Filters -- I just want mine to integrate with WYSIWYG.
Comment #101
Offlein CreditAttribution: Offlein commentedEr. Sorry, I see this is closed. I made a new issue: #1108324: Add input filter to HTML message for system and Rules actions
Comment #102
narcisgirona CreditAttribution: narcisgirona commentedI'm having trouble in order to get it work. Could you please help me a bit?
I have created a rule which sends an HTML email whenever a user posts an article. Everything seems to work but the attachments. I want to send the images the user posted on the article to the email but can't figure out how to do so. Again i'm able to send the body of the article, title (everything) but not the attachet images of the posted article.
I'm sure i'm doing something wrong on the section where i have to setup the attachments:
Attachments
The mail's attachments, one file per line e.g. "files/images/mypic.png".
Value
[
here i should use the path or token but have no clue how to implement it
]
Thanks man, hope to hear about you soon.
Comment #103
jday CreditAttribution: jday commented@narcisgirona
Get the token from the "Token replacement patterns" list, find the token for your image field
something like this: [node:field_image-filepath]
Comment #104
narcisgirona CreditAttribution: narcisgirona commentedHey @jday thanks for you help but unfortunately still not working.
on the Token replacement patter i just get one token [node:field_image]
here you have some screenshots:
THANKS for your help!
Comment #105
narcisgirona CreditAttribution: narcisgirona commentedI managed to make it work however just with and absolute path defined in the attachaments value:
If i save a file the file /sites/default/files/file_example.jpg then i would get the email with attachments but if i'm using the tocken:
[node:field_image] instead of /sites/default/files/file_example.jpg But i'm not getting the attached files.
I guess i should use [node:field_image:path] or something like that but can't find the option anywhere.
i tried with a few combinations:
[node:field_image:path]
/sites/default/files/[node:field_image]
/sites/default/files/[node:field_image:path]
/sites/default/files/"[node:field_image]"
"/sites/default/files/[node:field_image:path]"
...
Any help would be much apreciated
thanks