安装phplist的前期准备:
* apache http server 2.2 with openssl (一定要使用带openssl的,否则如果用gmail来发phplist 邮件时会有 SMTP Error: Could not connect to SMTP host.)
参考文章:
http://blog.csdn.net/cheng_tian/article/details/5839820
http://www.dreamweaver.com.tw/?fid=7&viewtopic=29692
http://blog.yogo.tw/2009/08/phpopenssl.html
1. download phplist latest version from http://www.phplist.com/download, and then unzip it. copy the whole "lists" folder in
"/public_html" to your web server (NOTE: DO NOT change the folder from "lists" to "phplist")
if you want to change folder name, please ref to http://forums.phplist.com/viewtopic.php?f=3&t=31920
2. create a database named "phplist"
3. modify following settings in <phplist_home>/config/config.php
$database_host = "localhost";
$database_name = "phplist";
$database_user = "root";
$database_password = 'xxx';
define ("TEST",0);
define("PHPMAILERHOST",'smtp.gmail.com');
$phpmailer_smtpuser = 'hkbu.chtl.tomson@gmail.com'; //remember to remove the comment char "#"!!!
$phpmailer_smtppassword = 'xxxx'; //remember to remove the comment char "#"!!!
4. download phpmailer v5.1 from http://phpmailer.worxware.com/, and then copy class.phpmailer.php and class.smtp.php to
<phplist_home>/admin/phpmailer folder and overwrite the old ones
5. add following codes in <phplist_home>/admin/class.phplistmailer.php after {$this->Mailer = "smtp";}
$this->Port = 465;
$this->SMTPSecure = "ssl";
6. go to http://localhost/lists/admin to install phplist
1) initial database
2) login with default admin account (name: admin, pwd: phplist)
3) change admin pwd
4) access "main page > configure" and modify following settings
"Person in charge of this system": hkbu.chtl.tomson@gmail.com
"From email address for system messages": hkbu.chtl.tomson@gmail.com
"What name do system messages appear to come from": CHTL
5) access "users > add a user" to add user (just fill in email and confirm fields) and enroll it to "test" list
7. access "send a message" to try to send an email.
1) access "send a message", fill in "subject", "campaign" fields, and click "save change" button. (you can click
"send test message" button to send a test email)
2) (optional) you can modify "Format", "Scheduling" tab setting
3) Click "lists" tab, select the list which will receive email, and then click "send campaign" button.
4) click "process the queue" link
5) done.
8. remove phplist logo footer in mail content
ref link:
http://www.xzer.com/index.php/archives/17
http://www.xzer.com/index.php/archives/187
1) in admin/sendemaillib.php file, find
$text["signature"] = xxx
change it as
$text["signature"] = "";
2) in admin/sendemaillib.php file, find(有3处)
$html["signature"] = xxx
change them as
$html["signature"] = "";
9. create/edit subscribe/unsubscribe page (用户可以从这2个page来subscribe/unsubscribe,缺省的subscribe page是phplist的,应该创建属于自己的page)
phplist online admin interface > main page > "edit a subscribe page" link
10. by default, there is always a footer in email content. the footer provides 3 links: "unsubscribe", "edit preferrence" and "forward". If you would like to modify default footer, do it at "configure > Footer used when a message has been forwarded".
install possible problems
*error: Database error 1071 while doing query Specified key was too long; max key length is 1000 bytes
solution:
ref link http://docs.phplist.com/PhplistTroubleshooting
search for the following line in lists/admin/structure.php
"user_blacklist_data" => array(
Find the entry for the email address which should be directly below the line above
"email" => array("varchar(255) not null unique","Email"),
and change it to this:
"email" => array("varchar(233) not null unique","Email"),
phplist issues
* how to disable subscribe and unsubscribe page?
by default, subscribe url is "/lists/?p=subscribe" and unsubscribe url is "/lists/?p=unsubscribe"。我一开始以为可以在phplist admin interface的"configure > URL where users can subscribe" and "configure > URL where users can unsubscribe"进行修改,哪知道不起作用。只好修改/lists/index.php的代码:
找到"switch ($_GET["p"]) {",把整个switch代码段注释掉,然后换成下面一行:
FileNotFound();
即可。
* phplist的unscribe page是没有authentication的,即如果我知道别人的email,我可以替他来unsubscribe。虽然phplist提供了在unsubscribe之前需要密码的选项,但使用这个功能需要在创建user时为其分配密码。这对于我们的需求不可行。我们希望当user要unsubscribe时,先进入我们的ldap login page,在login之后,根据login session来认证user。还没研究过如果做phplist和ldap进行integration,估计比较复杂。我决定用下面的简单方法:(注:ldap page和phplist不在同一个server)
1. 按前面所说的disable subscribe and unsubscribe page
2. 在phplist server添加一个php page "handle_unsubscribe.php",用于根据email param直接从phplist database里删除相应的record(s),从而把该email 从list里删除,达到unsubscribe的效果。
handle_unsubscribe.php:
<?php
if(!isset($_GET['user'])){
echo "Action denied!";
exit;
}
$db = mysql_connect('localhost', 'xxxx', 'xxxx') or die ('Unable to connect database.');
mysql_select_db('phplist', $db) or die(mysql_error($db));
mysql_query("set names utf8;");
$query="select * from phplist_user_user where email='{$_GET['user']}@xxx.com'";
$result = mysql_query($query, $db) or die(mysql_error($db));
if(mysql_num_rows($result)!=1){
echo "error: record num is not 1!!";
exit;
}
$row = mysql_fetch_assoc($result);
$query="delete from phplist_listuser where userid={$row['id']}";
mysql_query($query, $db) or die(mysql_error($db));
echo "success";
?>
3. in ldap page side, create a php file named "unsubscribe.php", which communicates with the php file created in above step 2
unsubscribe.php:
<?php
include("/home/chtl/public_html/restricted/hd.php");
require_once '../lib/_string_lib.php';
if(isset($_POST['submit'])){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://xxxx/handle_unsubscribe.php?user=".$_SESSION['_chtl_userid_']);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res=curl_exec($ch);
curl_close($ch);
if(startsWith($res, "success")){
//TODO: add log to db
echo "You have unsubscribe CHTL newsletter succesfully!";
} else
echo "Unsubscribe failed, please try later.";
exit;
}
?>
<form action="<?php $_SERVER['PHP_SELF']?>" method="post">
Do you really unsubscribe CHTL newsletter?
<input type="submit" name="submit" value="Confirm">
</form>
4. 然后在phplist admin interface "configuration > Default footer for sending a message",把content改为
--
If you do not want to receive any more newsletters, <a href='http://xxxx/unsubscribe.php'>this link</a>
这样,当你通过phplist send email时,就会提供http://xxxx/unsubscribe.php link供user通过ldap来unsubscribe。