|
|
[php] Simple Newsletter Script | ||
Discussion by cragllo with 22 Replies.
Last Update: March 10, 2012, 8:45 am ( View Rated (3) ) | |||
![]() |
|
|
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"> </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!
I will use it on my site when I get it up and running. Thank you.
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?
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.
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
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?
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
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
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
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
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
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.
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"> </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...
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.comLink: 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!
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?
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
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?
Similar Topics:
Email Script/form With Php
Very Simple Online Now Script
How To Make Php Newsletter Script
Half Life 2 Sig Tutorial Easy, good result. (14)
|
(18) Rounded Edges In Photoshop An easy way to do this
|
Loading...
HOME ![Quickly Post to [php] Simple Newsletter Script w/o signup](http://xisto.cachefly.net/ks/template/x/html//images/reply.png)

![email your friend about [php] Simple Newsletter Script](http://xisto.cachefly.net/ks/template/x/html//images/email.png)




