Loading...


bookmark - [php] Simple Newsletter Script

[php] Simple Newsletter Script

 
 Discussion by cragllo with 22 Replies.
 Last Update: March 10, 2012, 8:45 am ( View Rated (3) )
 
bookmark - [php] Simple Newsletter Script  
Quickly Post to [php] Simple Newsletter Script  w/o signup Share Info about [php] Simple Newsletter Script  using Facebook, Twitter etc. email your friend about [php] Simple Newsletter Script Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

This tutorial will give you the code needed and tell you how to implement it.

First off you need to create a file called mailing.php this will be the file that processes the adding of emails to the list.

CODE

<?php
$email = $_POST['email'];
$file = fopen("mailing.txt", "a");
fwrite($file, "\n" . $email);
fclose($file);

header("Location: mailing_thankyou.php");
?>


Next you need to create a file called mailing_thankyou.php, simple a page thanking them for signing up.

Now create a file called mailing.txt with nothing in it, when uploaded to the server set it writable (chmodd 666 or 777).

Now you need to form for teh people to enter their email address, put this on any page

CODE

<form action="mailing.php" method="post" class="style16">
<input type="text" name="email" size="30" value="your email here!">
<input type="submit" value="GO!" name="submit">
</form>


Now you need a file to send the newsletter, create a file called anything you want.

CODE

<?php
$send = $_POST['send'];
if($send){
$email = $_POST['email'];

$emailfile = file_get_contents("mailing.txt");
$emaillist = explode("\n", $emailfile);

foreach ($emaillist as $value)
{
mail($value, $_POST['subject'], $_POST['message'], "From: $email");
}

echo "<b>Email sent!</b><br />";
}
?>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<table width="481" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="84" align="right" valign="top" class="style32">Subject:</td>
<td width="397" align="left" class="style32">
<input name="subject" type="text" id="subject" size="41" maxlength="100">
</td>
</tr>
<tr valign="top">
<td width="84" align="right" valign="top" class="style32">From:</td>
<td align="left" class="style32"><input name="email" type="text" id="email" size="41" maxlength="100"></td>
</tr>
<tr valign="top">
<td align="right" valign="top" class="style32">Message:</td>
<td align="left" class="style32">
<textarea name="message" cols="37" rows="4" id="message"></textarea>
</td>
</tr>
<tr valign="top">
<td align="right" valign="top" class="style32">&nbsp;</td>
<td align="left" class="style32">
<input name="send" type="submit" id="send" value="SUBMIT">
<input name="Reset" type="reset" id="Reset" value="RESET">
</td>
</tr>
</table>
</form>


Thats you all done, to send the newsletter, simply go to the file you just created fill in the spaces, and click send, there is no warning/confirmation. so check before you send!

Please note: I will be improving on this script as time goes on, hopefuly to make it able to remove people from the list too, So check back soon!

   Thu Aug 4, 2005    Reply         

Great tut. Well explained and one of few I have seen on this topic.

I will use it on my site when I get it up and running. Thank you.

   Thu Aug 4, 2005    Reply         

Thats a good tutorial it will become very handy one day.

   Sun Aug 7, 2005    Reply         


Thank you so much. I am a dunce when it comes to PHP (I can understand it, but writing it is a different matter).

You would not believe the extenct of which I have searched the Internet trying to find such a script.

However, is it a flat file php script? There seems to be no mention of database, after all, wouldn't it need a database connection to retrieve the list of people who are signed up?

   Sun Aug 7, 2005    Reply         

thanx man i am going to put this script in my site.

   Mon Aug 8, 2005    Reply         

Nice script, i will defantly use this on my website =D

   Mon Aug 8, 2005    Reply         


QUOTE (pilgrim_of_minimonkeys)

Thank you so much. I am a dunce when it comes to PHP (I can understand it, but writing it is a different matter).

You would not believe the extenct of which I have searched the Internet trying to find such a script.

However, is it a flat file php script? There seems to be no mention of database, after all, wouldn't it need a database connection to retrieve the list of people who are signed up?


First of, I am exactly the same as you, I know how PHP works, what it can do, and I can easily edit php scripts, but writing my own is hord, I'm still learning but I know the basics and more.

Secondly, This scripts is flat file, all emails are saved in mailing.php (each on a new line), I am currently working on the part to search through that file and remove emails from the list.

   Mon Aug 8, 2005    Reply         

Cool. Thanks. I really need to start learning PHP.

   Mon Aug 8, 2005    Reply         

cool script -_-

   Tue Aug 9, 2005    Reply         

Great Script!! - newsletter sign up form php[php] Simple Newsletter Script

Excellent. Just installed this and worls perfectly. I literally spent hours looking for a simple script like this and no one had one. Every script was too complex or too hard to follow.  Nice job and thank you!

Also, all emails arrive in the text file. Can you show us how to import these into a database? Thanks again!

-reply by S-base

 

   Sun Mar 1, 2009    Reply         

Descriptive Title for Opinion/Feedback[php] Simple Newsletter Script

This worked perfectly! It collected emails and that isgreat. But I went to the file and entered a message, but I got aninternal server error.

Do I need to configure my hosting to send these and how do I do that? I host on Godaddy.Com.

Do I have to edit the php file to send emails?

 

   Sun Mar 1, 2009    Reply         

thx but need more help.[php] Simple Newsletter Script

I am new in PHP Programing and this is a great helping code for me but Please I need a little more addition can you please tell me how I get email address from database ..And can I send  html file attach with this?

-reply by brightmoon11

   Mon Jul 27, 2009    Reply         

remove email from list[php] Simple Newsletter Script

hi, I hope this help everyone.

this will remove email from list

 <?phpif( isset($_GET) and $_GET == "yes"){      $remove_email = $_GET;        $taken_email = array();         $emailfile = file_get_contents("mailing.Txt");   $emaillist = explode("and", $emailfile);     foreach ($emaillist as $value)   {      if ( $remove_email != $value ){        $taken_email[] = $value;      }   }        $value = "";    foreach ($taken_email as $value)   {      $email = $value;      $file = fopen("mailing.Txt", "w+");      fwrite($file, "and" . $email);      fclose($file);    }   }?>

-reply by majid

   Mon Sep 21, 2009    Reply         

remove email from list[php] Simple Newsletter Script

hi, remove email script, please ignore previous one...

 

<?phpif( isset($_GET) and $_GET == "yes"){      $remove_email = $_GET;        $taken_email = array();     $emailfile = file_get_contents("mailing.Txt");   $emaillist = explode("and", $emailfile);     foreach ($emaillist as $value)   {      if ( $remove_email != $value ){        $taken_email[] = $value;      }   }        $value = "";    $file = fopen("mailing.Txt", "w+");    foreach ($taken_email as $value)   {      if( trim($value) != "" ){        $email = $value;        fwrite($file, "and" . $email);      }    }        fclose($file);    }?>

-reply by majid

   Mon Sep 21, 2009    Reply         

Need more details please....[php] Simple Newsletter Script

Hi, I am setting up my first website through Website Tonight and am trying to figure out how to do an e-mail sign-up box for a newsletter. I see your instructions but I guess I don't know what php is, or where to create the files you say to create - is this all done on the website, or in Word, or in some other kind of program? I'm sorry for my stupidity - I am still learning!

-question by Caryn

   Wed Oct 7, 2009    Reply         

QUOTE (Gmajid)

remove email from list

[php] Simple Newsletter Script



<p>hi, remove email script, please ignore previous one...</p>
<p> </p>
<p><?php


if( isset($_GET['remove']) and $_GET['remove'] == "yes"){

 

   $remove_email = $_GET['email_remove'];

   

   $taken_email = array();

   

$emailfile = file_get_contents("mailing.Txt");

  $emaillist = explode("and", $emailfile);

 

  foreach ($emaillist as $value)

  {

     if ( $remove_email != $value ){

       $taken_email[] = $value;

     }

  }

   

   $value = "";

   $file = fopen("mailing.Txt", "w+");

   foreach ($taken_email as $value)

  {

     if( trim($value) != "" ){

       $email = $value;

       fwrite($file, "and" . $email);

     }

   }

   

   fclose($file);


   

}


?></p>

-reply by majid
Link: view Post: 460565


Hi,

After I upload the remove email script then what do I do to remove the emails from the mailing.txt? I tried

CODE

http://example.com/unsubscribe.php?email=example@gmail.com

   Thu Oct 8, 2009    Reply         

It would have to be site.com/remove.php?remove=yes&email_remove=email@domain.com

Judging by the two GET variables.

So you can send out a link with the newsletter with a premade HREF tag that plugs in the individual user's email address into the email_remove variable.

QUOTE

Need more details please....
[php] Simple Newsletter Script

Hi, I am setting up my first website through Website Tonight and am trying to figure out how to do an e-mail sign-up box for a newsletter. I see your instructions but I guess I don't know what php is, or where to create the files you say to create - is this all done on the website, or in Word, or in some other kind of program? I'm sorry for my stupidity - I am still learning!
-question by Caryn


I would strongly suggest looking for another script to send out newsletters, this isnt super beginner friendly (though its perfectly well made!). If you want to host a reliable site you will need to learn a bit about how the web works and at least touch upon HTML, just to fix little bugs in code etc....

To create a website you need to create code, HTML to be precise, this is done usually in a specific editor, things like Word really arent any good, even though they will tell you they can create websites they really cant and you will run into endless problems. PHP is just another type of code that works in the background. Like the engine of a car, you as a driver never see it, you just give it input (gas, change gears, ignition) and it does some work that you know nothing about, all you know is that the car starts and changes speed. Thats PHP. The bodywork of the car is like HTML, you see it, it holds everything together where the engine (or PHP) does all the heavy work in the background.

   Thu Oct 8, 2009    Reply         

QUOTE (cragllo)

This tutorial will give you the code needed and tell you how to implement it.

First off you need to create a file called mailing.php this will be the file that processes the adding of emails to the list.

CODE

<?php
$email = $_POST['email'];
$file = fopen("mailing.txt", "a");
fwrite($file, "\n" . $email);
fclose($file);

header("Location: mailing_thankyou.php");
?>


Next you need to create a file called mailing_thankyou.php, simple a page thanking them for signing up.

Now create a file called mailing.txt with nothing in it, when uploaded to the server set it writable (chmodd 666 or 777).

Now you need to form for teh people to enter their email address, put this on any page

CODE

<form action="mailing.php" method="post" class="style16">
<input type="text" name="email" size="30" value="your email here!">
<input type="submit" value="GO!" name="submit">
</form>


Now you need a file to send the newsletter, create a file called anything you want.

CODE

<?php
$send = $_POST['send'];
if($send){
$email = $_POST['email'];

$emailfile = file_get_contents("mailing.txt");
$emaillist = explode("\n", $emailfile);

foreach ($emaillist as $value)
{
mail($value, $_POST['subject'], $_POST['message'], "From: $email");
}

echo "<b>Email sent!</b><br />";
}
?>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<table width="481" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td width="84" align="right" valign="top" class="style32">Subject:</td>
<td width="397" align="left" class="style32">
<input name="subject" type="text" id="subject" size="41" maxlength="100">
</td>
</tr>
<tr valign="top">
<td width="84" align="right" valign="top" class="style32">From:</td>
<td align="left" class="style32"><input name="email" type="text" id="email" size="41" maxlength="100"></td>
</tr>
<tr valign="top">
<td align="right" valign="top" class="style32">Message:</td>
<td align="left" class="style32">
<textarea name="message" cols="37" rows="4" id="message"></textarea>
</td>
</tr>
<tr valign="top">
<td align="right" valign="top" class="style32">&nbsp;</td>
<td align="left" class="style32">
<input name="send" type="submit" id="send" value="SUBMIT">
<input name="Reset" type="reset" id="Reset" value="RESET">
</td>
</tr>
</table>
</form>


Thats you all done, to send the newsletter, simply go to the file you just created fill in the spaces, and click send, there is no warning/confirmation. so check before you send!

Please note: I will be improving on this script as time goes on, hopefuly to make it able to remove people from the list too, So check back soon!
Link: view Post: 169995

I wanted this script for my website so now I will not have search the sollution it seems simple. Thanks for tutorial...

   Thu Oct 8, 2009    Reply         

QUOTE (afunguy26)


Hi,

After I upload the remove email script then what do I do to remove the emails from the mailing.txt? I tried

CODE

http://example.com/unsubscribe.php?email=example@gmail.com


Link: view Post: 461545


I am also wondering how to remove email with this code. Thanks for the script. I added a wysiwyg editor to this script to send HTML emails. Worked like a charm!

Thanks!

   Wed Oct 27, 2010    Reply         

QUOTE (Denny)


I am also wondering how to remove email with this code. Thanks for the script. I added a wysiwyg editor to this script to send HTML emails. Worked like a charm!

Thanks!

Link: view Post: 498365



Hello can share the script with the wysiwyg editor you added please?

   Wed Aug 31, 2011    Reply         

Some free php newsletter scripts listed on: http://www.phpnewsletter.org/download.html

   Fri Nov 4, 2011    Reply         

hello,i was wondering how i can edit textarea? or instead of textarea can i put reguar html code?
like "div style="width:500px;backgorund-color:#eee">
<a href="#" > click here</a> </div>"

instead of textarea i want to style message with link and button..how can i do it?

thank you

   Fri Jan 20, 2012    Reply         

Hello there!

Thank you very much for the script, it works perfectly. I only have one issue and maybe it is my fault but if you try to access the txt file by writing the full address (i.e http://www.yourdomain.com/mailing.txt) anyone can see the full list of subscribers... Is there any way to make that hidden or something?

   Sat Mar 10, 2012    Reply         

Quickly Post to [php] Simple Newsletter Script  w/o signup Share Info about [php] Simple Newsletter Script  using Facebook, Twitter etc. email your friend about [php] Simple Newsletter Script Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

Similar Topics:

Email Script/form With Php

Today, I'm going to show you how to make an email script using PHP and HTML. Most people usually put <a href="mailto:blahblah@blah.blah">Email me</a> if they want an email link on their site, but there are several cons to this. First, it& ...more

   18-Apr-2005    Reply         

Very Simple Online Now Script

Hi all, Its Aldo. anyways, I wont be using the method of pagination, i will just tell you how to make a basic online now script. When someone logs in, now take into consideration that the name of the username input is username (<input type.... name=username) First , ...more

   29-Aug-2007    Reply         

How To Make Php Newsletter Script

I have seen a post on here somewhere which shows how to make a simple newsletter php script. I cvant find it anywhere and I wanted to ask some questions of the author. Does anyone know the one I mean? Cheers ...more

   28-Jul-2008    Reply         

Half Life 2 Sig Tutorial Easy, good result.   Half Life 2 Sig Tutorial Easy, good result. (14) (18) Rounded Edges In Photoshop An easy way to do this  Rounded Edges In Photoshop An easy way to do this