Closed (fixed)
Project:
Mime Mail
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
24 May 2011 at 18:55 UTC
Updated:
30 Oct 2011 at 17:09 UTC
Jump to comment: Most recent file
Hello,
We are using mimemail for some of our sites.
One client got a particular request, asking us to send all mails in HTML except for a particular form.
I did this small patch allowing us to use in $message a key: plaintext.
Once this key is set, it means that the message have to be sent in plaintext.
You can easily put in in a hook_mail_alter() and have your mail sent in plain text, with or without attachements.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | mimemail_1167576_13.patch | 1.81 KB | sgabe |
| #14 | allow_plaintext_email-1167576-11.patch | 3.38 KB | pol |
| #14 | allow_plaintext_email-1167576-12.patch | 3.38 KB | pol |
| #13 | allow_plaintext_email-1167576-9.patch for 6.X-1.X | 3.38 KB | pol |
| #13 | allow_plaintext_email-1167576-10.patch for alpha8 | 3.38 KB | pol |
Comments
Comment #1
polThe patch version 1 is for Mimemail 6.x-1.x.
Comment #2
polThe patch version 2 is for Mimemail 6.x-1.0-alpha8.
Comment #3
sgabe commentedSeems reasonable, but I would stick with the current coding style and do this:
It's enough to attach patches against the development branches. Patches against previous versions are quite useless. :)
Comment #4
polHello sgabe,
If the
$plaintextvar is set and$textempty, the mail sent will be empty, that's why I did this way.if and only if the
$plaintextis set, it will be sent in plaintext.Now it's up to you to decide of course, but both solutions are good for me.
About the patches for alpha8, we are using Jenkins at work and we avoid using dev versions, that's why I always post a patch against the latest 'stable' release, so Jenkins can download it during the build, and we are sure that this won't fail.
Anyway, this is the patch with your modification for the dev version.
Comment #6
sgabe commentedIf $text is empty, mimemail_html_body() should create automatically the text alternative. If that's not the case, it seems we have a bug.
Comment #7
polHello sgabe,
I made further tests this morning and I have found a working solution.
The assumption in #6 is not working.
If you do not provide the $text variable,
mimemail_html_body()should create it.But, the line
$text = preg_replace('|<style.*?</style>|mis', '', $body);always returns an empty string.I cleaned the whole stuff by doing this:
And that's working pretty good.
If you do not submit the
$message['text'], mimemail will built it.If it's submitted, then it will use it, as is.
This patch is for the 6.X-1.X version, I'll provide the patch for 6.X-1.0-alpha8 in a few minutes.
We are already using the code in pre-production project and we are happy with it.
Comment #8
polThis patch is for Mimemail 6.x-1.0-alpha8.
Comment #9
sgabe commentedThen we need to deal with #1116930: No text alternative if the CSS is too large first. So far I couldn't reproduce this, I will take a look at it again.
Comment #10
polNew patch, also fixing #1116930: No text alternative if the CSS is too large (hard one!) for Mimemail 6.X-1.X.
Comment #11
polSame as #10 for Mimemail 6.X-1.0-alpha8
Comment #12
polSmall php typo in #11, fixed in this patch.
Comment #13
polGRRR !
Bad function name, these patch are for 6.X-1.X and alpha8.
These patches cancel #12, #11, #10.
Comment #14
polAdding a
trim()to remove useless spaces in the cleaned body.Comment #15
sgabe commentedThank you for your work on this, Pol! Please do not create aggregated patches, let's deal with the issues separately.
Comment #16
sgabe commentedCommitted to the development snapshot. Thank you Pol!
Comment #17
polThat's great :-) You're welcome !
Thanks !
Comment #19
polPlease, do not forget to include authoring informations when you commit...
Thanks !