Forum Moderators: coopster

Message Too Old, No Replies

PHP newsletter

         

tr8er8

1:49 am on Feb 9, 2008 (gmt 0)

10+ Year Member



Can anyone help me make a newsletter script, so people will type in their email, then it will import it into a database. Then also how do I make an html email send or whatever? I dont need it to be complicated, just so I can view all the emails at once.

barns101

4:32 pm on Feb 10, 2008 (gmt 0)

10+ Year Member



I dont need it to be complicated...

Sorry, it is fairly complicated and probably not something where somebody will write the code our for you. :)

You could look at installing one of the many open source PHP mailing list packages. Try Hot Scripts [hotscripts.com] or SourceForge [sourceforge.net].

If you want to build it yourself, it's not too difficult provided that you don't require very many features and you'll be using it yourself (i.e. you won't have to teach anyone else what to do).

Here's what you'll need to do. It may look daunting but each bit on its own is not too complicated.

1) Build the HTML form where a user can input their name and email address. (Ideally I would add some sort of CATPCHA to stop automated signups.)

2) Write the PHP code to add the name and email address to your database. I would go down the double opt-in route: have a field in the database to specify whether the user has confirmed their registration. Initially set this to "no".

3) Write some PHP code to email the new "member" with a welcome message including a link that they must follow in order to confirm their registration.

4) Write some PHP code to set the "confirmed" field in the database to "yes" once the new "member" has followed the link.

5) Write the mailer script itself. For a list of maybe a couple of thousand "members" all it needs to do is select all the confirmed email addresses from the database and then run a while() loop that uses the mail() [php.net] function to send an email to everyone. In the headers of the emails you simply need to specify that the email is text/HTML and then you can compose the HTML offline and paste it into a form that feeds it into your while() loop.

I hope that makes sense. :)

Each bit on its own is not too complicated as long as you know how to insert data into a database; update that data; pull data out of the database and run a loop on each row; use the mail() command.

If you need any help with the code (other than writing all of it for you ;) ) I'm sure someone will help.