Would it be that hard to add some personalization variables to the newsletter?
As well as making the newsletters nicer, it would help them get delivered, since many of the junk mail filters (such as spamassassin) give points against email messages that have no personal greetings line.

At the moment we have: %site (the name of your website), %uri (a link to your homepage), %uri_brief (homepage link without the http://), %mymail (your e-mail address), %date (today's date), %login_uri (link to login page).

What I would like to see is:
1. a variable %user which defaults to a value of "subscriber" if the subscriber doesn't have an account.
2. a variable %profile_xxxx which pulls a value from the user's profile, from field xxxx
-there would have to be some way of defining a default for this in the syntax if there is no content to this field or if the subscriber doesn't have an account.

If someone would point me in the right direction, I would have a go at doing this.

Comments

AlanT’s picture

+1 on this. A few more variables shouldn't conflict with the 'simpleness' of the module, and will make the communication that much more effective.

sun’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev
Assigned: Unassigned » sun
sun’s picture

Status: Active » Needs review
StatusFileSize
new5.21 KB

I needed this functionality for an accounting system we're developing on Drupal.

The attached patch basically allows to insert user profile fields into newsletters. However, these tokens should be used carefully as you do not know which profile fields a user has filled in and because there is no profile information for anonymous recipients (without a user account) at all. I'm currently unsure how to handle those conditions. It might be that there are only limited solutions to this issue, such as (optionally) sending a newsletter to recipients that have filled in the required fields.

Anyhow, IMHO this approach should be converted into a new hook_simplenews_fields(), so any module is able to provide additional (text replacement) fields for newsletters. F.e. you can think of amount of unread private messages, time since last login, birthday reminders, etc.

Tobias Maier’s picture

what about utilizing the token module instead of reinventing the wheel?

read more about its features at http://drupal.org/project/token

andrewfn’s picture

Excellent idea! +1 from me.

sun’s picture

Token module currently does not support profile fields. However, smk-ka is already working on this implementation over here.

Petra’s picture

StatusFileSize
new3.4 KB

I'm also interested in personalizing newsletters. Make profile fields available is a good idea. But I only need 'username' to write "Hello username" in a newletter, so I used user-token to get this.

[reg-since] and [log-since] only show years and weeks, so I didn't insert them in the description.

To get the send-variable in simplenews_view() I used $_POST, because it was the only way I found.

I inserted token_replace() in simplenews_mail_send(), as in simplenews.module_5.patch - perhaps there is a better place.

Can anybody have a look at the code. I don't know how to make it better.

sgdev’s picture

Version: 5.x-1.x-dev » 5.x-1.5
StatusFileSize
new6.71 KB

I implemented the Token module patch for profiles, but it did not seem to fully meet my needs.

Then I tried the above patches in #3 and #7 together to cover all conditions. These definitely seem to work.

What's the possibility of getting #3 and #7 rolled into the next version of Simplenews, or are there other plans for Token which will meet these needs? If it makes sense to get them into Simplenews, I've created an updated patch. It is attached and has been tested with 5.x-1.5.

WeAreGeek’s picture

StatusFileSize
new4.86 KB

Hi,

All of the above patches failed to apply to the current stable release.
With the patches from #3 and #7 one hunk failed.
The patch in #8 didn't work at all, because it was malformed.

Please look into this again.
In the meantime I'll try and check what went wrong. If it works, I'll post a new diff.

Raoul

[edit] Patched it (#8) manually, against 5.x-1.5, tested, and it seems to work. Please see the Diff attached and review. Thanks.[/edit]

[edit 2] Actually, the profile fields don't work, whether I'm using the @profile_name or %profile_name variable. The tokens work perfectly though. I need to review my patch.[/edit]

sgdev’s picture

Patching manually using #8 should work with no problem, including the profile options. I've got it running on a live production site right now.

callison’s picture

Also see http://drupal.org/node/127178 for similar request.

sutharsan’s picture

Status: Needs review » Active

@callison: This issue is about token integration, i.e. using personal data not about collecting it.

Jean-Philippe Fleury’s picture

Subscribing

sutharsan’s picture

Version: 5.x-1.5 » 7.x-1.x-dev
Assigned: sun » Unassigned
Status: Active » Closed (duplicate)

Duplicate of #183120: Support Token module. Changing version to HEAD.
Where possible code of these patches will be used for HEAD.

kenorb’s picture

claudiu.cristea’s picture

Try Views Send. It allows personalization and full recipient list filtering based on Views.