Jump to content

email question


begeiste

Recommended Posts

hi,

 

I have just created a email blast in the php along with a table subscribers in the photos database, and tested at http://localhost:8888/24/emailblast.php. Not sure why it didn't show me the result after I sendt the testing News letter to those email records which has been inserted into database table 'subscribers' from database 'photos'?

 

Any inputs will be great appreciated!!!

 

<?php
if($_POST[op] !="send"){
//haven't seen the form, so show it
echo "
	<html>
		<head>
		<title>Sending a Email blast</title>
		</head>
		<body>
		<h1>Send a News Letter</h1>
		<form method=\"post\" action=\"$_SERVER[php_SELF]\">
			<p><b>Subject:</b><br>
			<input type=\"text\" name=\"subject\" size=30></p>
			<p><b>Mail body:</b><br>
			<textarea name=\"message\" cols=50 rows=10 wrap=virtual></textarea>
			<input type=\"hidden\" name=\"op\" vaule=\"send\">
			<p><input type=\"submit\" name=\"submit\" value=\"Send It\"></p>
		</form>
		</body>
	</html>";
}else if ($_POST[op] == "send"){
//want to send form, so check for required fields
if(($_POST[subject] =="") || ($_POST[message] == "")){
	header("Location: emailblast.php");
	exit;
}
//connect to database
$conn = mysql_connect('localhost','root','root');
mysl_select_db('photos') or die(mysql_error());

//get emails from subscriber list
$sql = "select email from subscribers";
$result = mysql_query($sql) or die(mysql_error());

//create a from: mailheader
$headers = "From: Your Mailing List <you@yourdomain.com>";
//loop through results and send mail
while($row = mysql_fetch_array($result)){
	set_time_limit(0);
	$email = $row['email'];
	mail("$email", stripslashes($_POST[subject]),stripslashes($_POST[message]), $headers);
	echo "newsletter sent to: $email<br>";
}
}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.