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 <[email protected]>";
//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
https://forums.phpfreaks.com/topic/71627-email-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.