plugins:mynewsletter

NP_MyNewsletter.php

blogの新着記事をメール配信するプラグインです。

cronを利用できないサーバの場合、WebCronやpseudo-cronなど。

本家版ではメールに日本語を含むと送信できないようです。日本語対応情報

General Plugin info
作者: TeRanEX
最新のバージョン: 1.2 (2005-8-26)
入手先: Nucleus Plugin: NP_MyNewsletter
ソース:
動作サンプル:
フォーラム参照先: NP_MyNewsletter: send completely customizable newsletters!

インストール方法

  1. プラグインをインストール
  2. プラグインオプションを設定
  3. Newsletter 用のスキンを作成
  4. Let your visitors register
  5. Personalize the templates
  6. メールの送信テスト
  7. CRON job を設定

プラグインオプション

The plugin has quite a few options:

Language for the plugin

With this option you can choose a translation for the plugin. Please see Translations for more info. Deafult value: default

Checkword

This is like a password. When you want to send the newsletter you’ll have to provide the right checkword. This is to prevent visitors and bots from accidentally sending the newsletter. After you install the plugin you should change this checkword, so that it is not the default value! Default value: MyNewsletter

Encoding for your mails

This is the encoding that will be written into the e-mail header (might be useful..) Default value: UTF-8

Send your mails as:

Using this option you can choose to send HTML-mails (using content-type text/html) or plaintext-mails using text/plain. If you choose to send plaintext-mails you should of course not use html-tags in your newsletter-skin, and the plugin will try to strip all html-tags before sending the mails. Default value: HTML

Send individual mails

When sending a newsletter the plugin can send an individual, personalized mail to every user or you can choose to send only one e-mail (in this case the BCC-field is used). Individual mails are nicer (because they can be personalized), but need more resources to send (more server load) Default value: Yes

Subject of mail

The subject of your newsletter, by example “Daily update of Tom’s blog” Default value: Daily update of my blog

Mail address of sender

The e-mail address that is used as the sender of your newsletter. This address is also used to send notifications when sombody subscribes/unsubscribes, so if you want to use that option you should change this e-mail address to be a valid one. Default value: noreply@example.com

Name of sender

The name that is used as the sender of your newsletter Default value: My blog

Send "welcome" (and "sorry to see you go") mails?

If this option is set to yes, the plugin will send a welcome (or sorry-to-see-you-go mail) when a visitor subscribes to your newsletter (or unsubscribes). You can personalize these mails by editing the templates. Default value: Yes

Notify me via e-mail when somebody (un)subscribes

If this option is set to yes the plugin will send an e-mail to the e-mail address you provided in ‘Mail address of sender’, every time a user subscribes or unsubscribes to your newsletter. You can personalize these mails by editing the templates Default value: Yes

Only send mail when there are new items?

If this option is set to yes the plugin will check the date of the most recent item and compare it with the ‘Timestamp of last time a newsletter was sent’ to see if there are new items since the last time a newsletter was sent. Only if there are new items a newsletter will be sent. If this option is set to No, the plugin will always send a newsletter even if there are no new items. (if you set the option to ‘yes’, and want to force the plugin to send a newsletter even if there are no new items you can append force=true to the url, see below) Default value: No

Page to redirect visitors when successfully subscribed

People that successfully subscribe to your newsletter will be redirected to this page (you can by example redirect them to a page saying “thank you for registering”) Default value: (url of your blog)

Page to redirect visitors when successfully unsubscribed

People that successfully unsubscribe from your newsletter will be redirected to this page Default value: (url of your blog)

Timestamp of last time a newsletter was sent (Blogoption)

This option is used by the plugin to store the date and time of the last time a newsletter was sent, so it can find out if there are new items before sending. You should NOT change the value for this option (unless you really know what you are doing )! (As of v1.2 this option will be read only when using Nucleus 3.1+CVS or higher)

Newsletter 用スキンの作成

To produce the newsletter the plugin uses a normal Nucleus Skin, meaning that the look-and-feel is completely customizable! So create a new skin inside Nucleus (and call it by example ““MyNewsletter”“). The only part of the skin you need is the ‘Main Index’-part, if you want to send the latest X items, or the archive part if you want to send the items of today (or yesterday, or maybe even this month ) Just edit the skin untill it looks like you want your newsletter to look like. You can also use some dynamic-variables in the skin to personalize the newsletter. Here are some usefull tips:

  • In the <head>-part of your skin add <base href=”http://example.com/blog/” />, where http://example.com/blog/ is the url of your weblog. If you do not add this e-mail clients can not handle relative url’s correctly (they will think that it points to some place on the receivers’ computer) (you can use by example: <base href=”<%blogsetting(url)%>” />;
  • Do not use too many html-codes. Spamdetection software might think that your newsletter is spam if you use a lot of html in it.
  • If you want to use CSS in your layout put it inside the <head> of your skin. This prevents e-mail clients from having to load it from the internet.
  • Do not use too many images in your skin. Images must be loaded from the net, and some mail clients might even block images to prevent a persons privacy.

After creating your skin add <%MyNewsletter(start)%> to the top of your skin (so that it is the very first thing in the skin) and <%MyNewsletter(stop)%> at the end of your skin (so that it is the very last thing in the skin) (see below for more on this)

The subscribe form

To let your visitors subscribe (or unsubscribe) to your newsletter, you can use the subscribe form in your normal skin by adding <%MyNewsletter(form)%> somewhere in the skin. When a visitor subscribes himself using this form he will be subscribed for the newsletter of the current blog. You can customize this form by editing ‘subscribe-form.inc.php’ in the ‘mynewsletter’-folder. I also provided an alternate form for people that have more than one blog and want let the visitor select the blog to which they want to subscribe by choosing it from a dropdown-list. To use the alternate form, simply rename ‘subscribe-form.inc.php’ to by example ‘subscribe-form.inc.php.bak’ and rename ‘subscribe-form.alternate.inc.php’ to ‘subscribe-form.inc.php’.

Personalize the templates

You can change the mails that are send to welcome a new subscriber or when he unsubscribes from your newsletter. Also the notification mails can be personalized. To do this simply edit the .template files in the folder of the language you have selected. Following templates are available:

  • welcome.template: sent to welcome a new subscriber
  • byebye.tempate: sent when a subscriber unsubscribes himself from your newsletter
  • notify.sub.template: sent to notify you when a new user subscribed to your newsletter
  • notify.unsub.template: sent to notify you when a user unsubscribed himself

In these templates you can also use the dynamic variables

Send a testmail

After you completely set up all the options, skin, templates,.. you can send a first testmail. You do this by browsing to the url like: http://example.com/weblog/?skinid=5&checkword=MyCheckword&testmail=you@example.com . This supposes that:

  • the skinid of the skin you created for your newsletter is ‘5’ (you can see this in the status by when you are in the admin area and hover your mouse over the skin)
  • MyCheckword is the checkword you choose in the options. If you do not provide this, or provide a wrong checkword the plugin won’t send any mail and tell you the checkword is wrong!
  • you@example.com is the e-mail address where you want to receive the testmail. (this should be a valid mail address ofcourse)

You can always send a testmail to check if everything works or while you are creating a new layout for your newsletter (using a different skin), so you can preview it. Testmails are only sent to the address you enter in the url so it is save to send a testmail even if there are already people subscribed to your newsletter.

Sending the newsletter

After you have edited all the options, created a skin, personalized the templates and successfully sent a testmail you can finally start sending your newsletter You can do this manually, or by using a cronjob. In both cases somebody (or in case of the cronjob: something (meaning: the server)) will have to browse a special page to start sending the newsletter. So to manually send the newsletter enter http://example.com/weblog/?skinid=5&checkword=MyCheckword in the address-bar of your browser and hit enter. If everything is ok your newsletter will now be sent. In this url you have the following parts which you should change according to your nucleus setup:

  • the skinid of the skin you created for your newsletter is ‘5’ (you can see this in the status by when you are in the admin area and hover your mouse over the skin)
  • MyCheckword is the checkword you choose in the options. If you do not provide this, or provide a wrong checkword the plugin won’t send any mail and tell you the checkword is wrong!

Important: If the blog for which you want to send the newsletter is not the default blog you’ll have to add an extra parameter to the url: &blogid=7 (where 7 is the id of the blog for which you want to send the newsletter)

Setup a cronjob

You can setup a cronjob at the server to automatically send a newsletter every once in a while, by example every day at 10:00. To do this you must be able to create cronjobs at the server (contact your ISP for more info on setting up cronjobs). In the cronjob you should setup a command to let the php interpreter execute the same page as you would visit to manually send the newsletter. The command of a possible cronjob could be: /usr/bin/php /home/user/www/weblog/index.php skind=5 checkword=MyCheckword (where /usr/bin/php is the path to the php-interpreter and /home/user/www/weblog/index.php is the path (not url!) to the index.php file of your weblog. As an alternative it should also be possible to use the ‘curl’-command: curl http://example.com/weblog/?skinid=5&checkword=MyCheckword

スキンへの記述

Following is an overview of all available skinvars and their meaning:

  • <%MyNewsletter(start)%>: Marks the start of your newsletter in the skin. In most cases you will use this skinvar as the very first thing in the newsletter skin
  • <%MyNewsletter(stop)%>: Marks the end of your newsletter in the skin, and starts sending the newsletter. In most cases you will use this skinvar as the very last thing in your newsletter skin.
  • <%MyNewsletter(form)%>: Writes the subscribe/unsubscribe into a normal skin to let your visitors subscribe to your newsletter
  • <%MyNewsletter(vars, poweredby)%>: Writes a ‘powered by’ sentence in the skin. If you like Nucleus considering adding it to spread the word
  • <%MyNewsletter(vars, datetime, [notation])%>: This can be used in your newsletter-skin to write the current date in the newsletter. The [notation]-part should be a valid php-date-format

Dynamic variables

In your newsletter skin and in the templates you can use some dynamic-variables to personalize the newsletter. Keep in mind that this will only work in the skin if the option ‘Send individual mails’ is set to ‘yes’.

  • $%MYNEWSLETTER_EMAIL%$: will be replaced by the e-mail of the subscriber (usefull to create an unsubscribe link inside the mailinglist)
  • $%MYNEWSLETTER_NAME%$: will be replaced by the name of the subscriber, by example to personaly greet him

Translations

As of v1.2 there is a ‘language selector’ build into the plugin. This means that you can simply select the language you want to use. (the pluginoptions themselves will not be translated!). Adding new languages is easy: If you downloaded a new language simply upload that folder (by example ‘french’) to mynewsletter/lang/, then edit the options of the plugin (by choosing ‘edit options’ in the Nucleus Admin Area) and refresh the page (using the refresh button of your browser or simply <F5>). MyNewsletter will then auto-detect the new language and add it to the select-box. Adding or modifying your own language is also easy: copy an existing language directory, rename it and edit the files. (if you made a translation for a language which is not yet provided with the plugin please give a shout so i can include it in the next release of the plugin!)

Logging

The plugin uses the Nucleus build-in logging system to log when a newsletter was send (or when somebody tried to send a newsletter but failed), and when visitors subscribe/unsubscribe. You can see this log by choosing ‘Action log’ form the quickmenu in the admin area.

I want to send the items of today (or yesterday)

Instead of sending the lates x-items of your blog you can choose to send all items of ‘today’ (or yesterday or this month or…) To do this simply use the ‘archive’-part of the newsletter skin instead of the ‘main index’-part and add an extra parameter, ‘archive’, to the url when sending the newsletter, to specify the day (or month) of which you want to send the items. To make it even easier I created two files called ‘today.php’ and ‘yesterday.php’, which can be found in the ‘mynewsletter/extra’-folder. Simply copy these files to the root of your Nucleus installation. Now you can browse to http://example.com/weblog/today.php and you will see only the items of today, to send the newsletter simply add the skinid and checkword parameters to the url. (same for yesterday.php ofcourse)

開発履歴

  • Version 1.2 (2005-8-26):
    • CHANGED: Added the plugin to the Nucleus Plugs project at ““SourceForge””
    • ADDED: An updater-plugin to upgrade from earlier versions (can be found in mynewsletter/extra/)
    • ADDED: Language Selector to choose the language of the plugin as a plugin option
    • ADDED: A completely new Admin Area, where you can view, delete and add subscribers
    • CHANGED: _getSubscribers() now returns an array instead of a mysql result, and accepts some (optional) parameters: $blogid, to select a blog (0 returns subscribers for all blogs), $start and $end, to limit the result (used when called from inside the admin area)
    • CHANGED: the lastsent-option is now readonly (only on Nucleus 3.1+CVS and higher)
    • CHANGED: moved all functions from general.inc.php into the pluginclass, and removed general.inc.php
    • CHANGED: the templates now show the name and e-mail address of the subscriber (only the ones sent to the subscriber show his e-mail address for his privacy) and use nicer HTML
    • CHANGED: the templates to look nicer when mails are sent as text/plain
    • CHANGED: errors while (un)subscribing are now handled using the doError()-method, when successfully (un)subscribed people are redirected to a ‘succes’-page. (as suggested by Weps)
    • CHANGED: the description of the plugin
  • Version 1.1-4 (2004-08-11):
    • FIXED: While fixing the previous bug I made a new bug… (found by Weps)
  • Version 1.1-3 (2004-08-11):
    • FIXED: in the notify-templates the ‘mail address of sender’ was used instead of the mail address of the subscriber when using dynamic variables (found by Weps)
  • Version 1.1-2 (2004-08-10):
    • CHANGED: renamed help.php to help.html according to the changes of CORE in CVS
    • CHANGED: the sort order of this history
  • Version 1.1 (2004-08-09):
    • ADDED: The dynamic-variables can now also be used in the templates
    • CHANGED: skinvar (vars, date) into (vars, datetime) in the manual
    • ADDED: the tip about blogsetting(url) for the base-element
    • FIXED: a bug with the uninstall query
    • CHANGED: the install query to fix a bug (hope it works now)
    • CHANGED: some typos in the default language file
    • CHANGED: the lastsent-option into a blogoption, so that the plug stores the individual date and time for every blog.
    • ADDED: the curl-alternative for the cronjob (thx Jef Pober!)
    • ADDED: an option to make it possible to change the content-type of the mails, so that it is possible to send plaintext-mails.
    • ADDED: when a blog is deleted, the subscribers for that blog are also deleted.
    • ADDED: Dutch translation for the defines and templates.
    • ADDED: when the mails are sent as text/plain all tags are stripped
  • Version 1.0 (2004-08-05):
    • initial version
 
plugins/mynewsletter.txt · 最終更新: 2011/03/23 21:28 (外部編集)