While sending the newsletter through Mime Mail the recipient's text mail preference isn't taken into account, the attached patch loads the user.name and user.data in simplenews_get_subscription and passes the entire $subscription object to Mime Mail which uses it to decide if send the mail in plain text or in html format.
This patch depends on #400998: mimemail_prepare won't accept $plaintext = FALSE argument.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | simplenews.401014.patch | 1.18 KB | sutharsan |
| #8 | simplenews_mimemail.patch | 1.21 KB | miro_dietiker |
| simplenews_user_plaintext.patch | 2.54 KB | plach |
Comments
Comment #1
sutharsan commentedCode looks good but I like to see test results of this.
Moving this to HEAD since I will not put any new features in 6.x-1.x any more.
Comment #2
jdwfly commentedI used the patch at #400998: mimemail_prepare won't accept $plaintext = FALSE argument for mime_mail and then I applied this patch. I have been testing this and it seems to work like it is supposed to. This was a definite need for me because our users are somewhat particular about what types of emails we send them.
Comment #3
sutharsan commentedI'll do a final test and commit it to HEAD when I have a chance.
Comment #4
jdwfly commentedI'm not quite sure that this solution scales very well. All of my smaller scale tests worked fine without problems, but when I ran it for real it ended up sending out text emails to everyone. It could be that this logic is flawed? I'm going to be looking into it over the next few hours.
Comment #5
jdwfly commentedJust figured it out. Let me explain how I can about this.
I have two different types of subscribers. Ones without accounts and ones with accounts. The ones that have accounts have their text mail preference set and the ones without will receive whatever format the newsletter comes. In my case that is HTML. Since I needed to import several hundred accounts I ran a simple database query to update the data field for every user. This modification changed EVERY user account to have text emails only. This of course was fine for me because the only ones with accounts were supposed to get text email. The problem came because I did not realize that the anonymous user mail preference is used when the email address has no user account. So when I sent out my first mass mailing, everyone got a plain text email.
This took me a while to figure out (it was my own fault), but I still don't know exactly why it uses the anonymous user's mail preference for email addresses without a user account. All I know is when I removed the data from the anonymous user and tested the emails, it worked just like it should.
Comment #6
miro_dietikerThis patch does not apply to the current repo HEAD (2009-09-16).
The only thing that gets applied is:
Other things seems to be disappeared... even if i see that $subscription->data don't get loaded and can't be applied thus using drupal_unpack().
I don't understand jet why we really need this (missing) unpack. Any explanation, any reroll?
Comment #7
miro_dietikerstate transitions...
Comment #8
miro_dietikerInitially i wanted to fix this from an other perspective.
#581326: Mimemail integration wrong
Now i see that the fix overthere combined with one here is a perfect fix for the situation.
For more information please consider the other issue and related mimemail patch which is no more needed now.
Comment #9
miro_dietikerthat was a bit too fast. someone pls review.
Comment #10
dawehnerI would have used ? . Anyway, there are two coding problems in this line :p
if( and
]=='
Here is a tab.
I'm on crack. Are you, too?
This was just a coding style review :)
Comment #11
sutharsan commentedI've reworked the patch and committed to 1.x and 2.x branch. Fixes are available in the next dev release.
Comment #12
miro_dietikerLooks perfect. Thank you!