TIGblogs TIG | TIGblogs GROUP TIGBLOGS LOGIN SIGNUP
betzster's Blog
betzster's Blog
Setup a Mailing List

Apparently nobody needs to know how to setup a mailing list anymore. Try checking google, there’s not much to look through, unless you know what your looking for. A client wanted a mailing list, so this is what I found. The IMAP extension for PHP is what you need. Here is the basic script that I found to work:

<?php

$subscribers = “you@gmail.com, sub@scriber.com”;

//Open a POP3 Inbox
$stream = imap_open(”{localhost:110/pop3}INBOX”, “username”, “password”);
//Get the content of the first email
$content = imap_body($stream, 1);

//Send the mail to your subscribers
mail($subscribers, “Subject”, $content, “From: me@mysite.com”);

//Delete the Email so the script is ready for the next time
imap_delete($stream, 1);

?>

You have to setup an email account somewhere, preferably on your webserver, that would be the easiest place to get access, and send an email there. Run this script and it grabs the email and sends it to all of your subscribers and deletes the email so that it’s empty for the next time you send the script.

Now obviously you wouldn’t want to store the list of your subscribers in the script. I’ll end up storing them in a database and pulling all the email addresses out when I call the script.

Remember, this will only work if you have the IMAP extension installed on your server and you have to run this after you send the email so it might be a good idea to setup a cron job to run this at least a couple of times a day, depending on how important the emails are that you are sending out and how time sensitive they are. For a regular mailling list that is sent out weekly or maybe even less frequently than that a couple of times a day should be just fine. If you are going to use this as a listserv, you might want it to run more like once a minute.


June 7, 2008 | 4:06 AM Comments  0 comments

You must be logged in to add tags.


Josh's Profile


Latest Posts
Anything Slider: Go on...
Youtube, Vimeo Showing...
A Contact Page to...
Problems Getting...
Google Apps

Monthly Archive
April 2007
May 2007
June 2007
July 2007
August 2007
September 2007
October 2007
November 2007
December 2007
March 2008
April 2008
May 2008
June 2008
July 2008
September 2008
October 2008
November 2008
December 2008
January 2009
February 2009
March 2009
April 2009
May 2009
June 2009
July 2009
August 2009
September 2009
October 2009
November 2009
December 2009
January 2010
February 2010

Change Language


Tags Archive
apache apple asides band blog blogs coding design dreamweaver florida gallery general globalwarming hosting internet johnmayer network nifty php plugins school service tech theme themes twitter vacation web wordpress youtube

Links
High School Reunion
Josh Betz Blog
Josh Betz Professional
Josh Betz Projects


16971 views
Important Disclaimer