Hello, I found a script on a website but they don't have support for it and i was hoping ane of you guys could help me. The script is a E-mail List Subscription (you know, to subscribe for e-newsletters
). the problem here is that it won't send the message that is suppposed to send to every person in the mail list. can any body help me what is wrong with it?
The code is:
PHP Code:
<?
error_reporting(1);
//#############################################################
//################# CONFIGURATION ##########################
(I removed the password information for obvious reasons.)
$message_at_bottom="
------------------------------------------------------------
P.D.: To remove from this list go to...
[url]http://www.mydomain.com/emaillist.php[/url]
";
// The file where emails are stored
$emails_file="filename.ext";
//############### END CONFIGURATION ########################
//#############################################################
// IF INFO IS NOT POSTED, PRINT THE FORM AND DIE
if (!$_POST["mensaje"]){
print_form();
die();
}
// IF INFO IS POSTED YOU WILL BE HERE
// Check whether the password is correct
// (only webmaster is supposed to know the password, which has been specified above)
if ($_POST["p"]!=$my_password){die("You have entered the incorrect password / Haz introducido la contraseña incorrecta.");}
// Get the subject of message
$subject =$_POST["subject"];
// Get the body of message
$message=$_POST["mensaje"];
// Add to body of message the bottom
$message.=$message_at_bottom;
// Read the file with emails to variable $emails_file
$emails_file=file_get_contents($emails_file);
// Extract list of emails to array $emails_array
preg_match_all("/<.{0,100}?>/",$emails_file,$emails_array);
// Start output
print "<b>Sending messages / Enviando Mensajes...</b>";
// Send email to each email
foreach ($emails_array[0] as $email){
// remove "<" and ">" from each email
$email=substr($email,1,strlen($email)-2);
// Next line is the one sending the email: the key command of this script
mail("$email, $subject,$message, From: $from_email\nReply-To: $replayto\nContent-Type: text/plain");
// Each time an email is send, output it
print "<br>$email - message sent/enviado. \n" ;
// After sending each email, send previous line (the email) to the browser
flush();
}
?>
</body>
</html>
<?php
// THIS FUNCTION WILL SHOW THE FORM
// MODIFY IT AS REQUIRED
function print_form(){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>My email list</title>
<style type="text/css">
<!--
.style1 {font-family: Tahoma}
-->
</style>
</head>
<body style="background-color: rgb(255, 255, 255);">
<center>
<h2>Form to send email to the mailing list</h2>
<table style="font-family: times new roman;" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="vertical-align: top;">
<form method=POST action="<? $PHP_SELF; ?>".php>
<span class="style1">Subject </span><br>
<input type=text name=subject size=40>
<br>
<span class="style1">Message</span> <br>
<textarea name=mensaje cols=50 rows=8></textarea>
<br>
<span class="style1">Password</span>
<input type=password name=p size=10>
<br><input type=submit class="style1" value="Send >>">
</form>
</td>
</tr>
</tbody>
</table>
</center>
</body>
</html>
<? } ?>
Bookmarks