【问题标题】:PHP Subscribers Mailing List [closed]PHP订阅者邮件列表[关闭]
【发布时间】:2010-09-29 14:04:55
【问题描述】:

我需要为我正在建立的校友网站创建一个邮件列表。以下是我希望邮件列表发挥作用的理想方式。

用户
用户将访问网站,在字段中输入他们的电子邮件地址(可能还有名字/姓氏),单击订阅按钮,然后收到验证消息(通过弹出、重定向或电子邮件消息) .

网站管理员
每个成功订阅的电子邮件地址(和姓名)都会被编译成服务器上的文本文档或群组电子邮件地址。然后管理员可以使用管理员密码登录以向订阅者列表发送批量电子邮件(例如http://justincross.net/stuff/join2.php),或者管理员可以仅通过 G-Mail 帐户通过电子邮件发送列表。

有谁知道如何有效地做到这一点?我已经搜索了几天的教程/模板,但我尝试过的极少数似乎要么坏了,要么使用了 mySQL(我不想这样做)。

提前致谢!

【问题讨论】:

  • 您是否考虑过使用 Constant Contact 或 Mail Chimp 之类的东西?他们预先构建了很多这些东西,并且还可以管理列表中的某人选择退订的时间。大多数类似的电子邮件程序都有一个简单的复制/粘贴代码,允许该功能。

标签: php mailing-list subscribe


【解决方案1】:

数据库方式确实是最好的方式。如果您更愿意使用文本文件方法,我会建议如下:

向文件中插入数据

$email = "the email";
$firstName = "the first name";
$lastName = "the last name";

$new_line = "$email|$firstName|$lastName\n"; // |  could be other character

$file = fopen("subscribers.txt", "a");
fputs($file, $new_line);
fclose($file);

读取和解析数据

$subscribers = array();

$handle = @fopen("subscribers.txt", "r");
if ($handle) {
    while (!feof($handle)) {
        $line = fgets($handle, 4096);

        //parsing the line
        $ar = explode('|', $line);

        //$ar[0] holds the email
        if(key_exists(0, $ar)){
          $email = $ar[0];
        }else{
          $email= '';
        }

        //$ar[1] holds the first name
        if(key_exists(1, $ar)){
          $firstName = $ar[1];
        }else{
          $firstName = '';
        }

        //$ar[2] holds the last name
        if(key_exists(2, $ar)){
          $lastName = $ar[2];
        }else{
          $lastName = '';
        }

        $temp = array(
          'email' => $email,
          'firstName' => $firstName,
          'lastName' => $lastName
        );

        $subscribers[] = $temp;
        //

    }
    fclose($handle);
}

用于遍历订阅者并使用您的功能发送电子邮件

foreach($subscribers as $subscriber){
    //the email
    $subscriber['email'];

    //the firstname
    $subscriber['firstName'];

    //the lastname
    $subscriber['lastName'];
}

【讨论】:

  • 谢谢,马里奥!来看看这个,看看效果如何!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-08-10
  • 2010-12-20
  • 1970-01-01
  • 2011-11-11
  • 2020-02-08
  • 2019-03-25
  • 1970-01-01
相关资源
最近更新 更多