Show DevBest [PHP] Email Subscription Script

Status
Not open for further replies.

Jeffrey

Devbest Indian Tech Support
FindRetros Moderator
Feb 5, 2013
1,180
412
Hi here is a Email Sub. Script for People who want to have it,

* I DID NOT CREATE THIS, JUST POSTING IT*

HTML:
<form method="POST" action="enter the URL to your PHP page here">
<p>Name: <input type="text" name="Name" size="20"></p>
<p>Email: <input type="text" name="Email" size="20"></p>
<p><input type="submit" value="Submit" name="Submit"></p>
</form>
Create a new PHP file (e.g. subscribe.php) with any texteditor (e.g. notepad) and place it on your webserver.
Please update the URL in the HTML form. (e.g. subscribe.php)

PHP:
<?php
 
## CONFIG ##
 
# LIST EMAIL ADDRESS
$recipient = "enter the lists email address here";
 
# SUBJECT (Subscribe/Remove)
$subject = "Subscribe";
 
# RESULT PAGE
$location = "enter the URL of the result page here";
 
## FORM VALUES ##
 
# SENDER - WE ALSO USE THE RECIPIENT AS SENDER
# DON'T INCLUDE UNFILTERED USER INPUT IN THE MAIL HEADER!
# SEE ALSO: How to protect a php Email Form using php mail or mb_send_mail against Mail Header Injection
$sender = $recipient;
 
# MAIL BODY
$body .= "Name: ".$_REQUEST['Name']." \n";
$body .= "Email: ".$_REQUEST['Email']." \n";
# add more fields here if required
 
## SEND MESSGAE ##
 
mail( $recipient, $subject, $body, "From: $sender" ) or die ("Mail could not be sent.");
 
## SHOW RESULT PAGE ##
 
header( "Location: $location" );
?>
credits to
 

Sysode

Front-End Developer
Dec 11, 2012
1,673
848
Embed Ajax into this so it doesn't get annoying and re-directs you to another page.
Anyhow, there's plenty of these scripts lying around the interwebs. Thanks for the share.
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
This isn't an email subscription script, this just sends a mail. And as it isn't protected, people can use this to 'mailbomb' someone.
 

Jeffrey

Devbest Indian Tech Support
FindRetros Moderator
Feb 5, 2013
1,180
412
subscribe-webform.png
i found this from
 

Ruin

Member
Feb 23, 2013
118
6
I seen this somewhere else, just couldn't find it, thanks for the release.
 

Forget

Member
Apr 3, 2012
120
14
You will also need to install SMTP or another emailing server client, other wise the php code will not work since it needs to know who the email will be getting sent from.

This code does work though but could be edited to a more advanced look to be better:)!
 

Jeffrey

Devbest Indian Tech Support
FindRetros Moderator
Feb 5, 2013
1,180
412
I seen this somewhere else, just couldn't find it, thanks for the release.
Didnt you read the credits lol?
You will also need to install SMTP or another emailing server client, other wise the php code will not work since it needs to know who the email will be getting sent from.

This code does work though but could be edited to a more advanced look to be better:)!
Im working to edit this make it a better version.
 

Forget

Member
Apr 3, 2012
120
14
Im working to edit this make it a better version.
What are your intentional ideas for the update? are you going to uses a class and a public function so you only need one script and you can send many emails?

class (whatever name) {
final public function sentEmail($headers, $base, $email, $to)
{
Code...
}
}
 
Status
Not open for further replies.

Users who are viewing this thread

Top