Jump to content

DATABASE MAIL


shenmue232

Recommended Posts

Hi everyone

 

I have a table called tbl_emails with a column called email this table has a list of emails, what i want to do is email everyone in the table here is my code so far:

 

<?php ob_start();?>

 

<html>

 

<?php

 

$con = mysql_connect("");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("shenmue232", $con);// database name

 

$result = mysql_query("SELECT * FROM tbl_emails");

 

while($row = mysql_fetch_array($result))

  {

  echo $row['email'];

  echo "<br />";

  }

 

$comment =$_POST['comment'];

$email =['email']; 

     

 

mail ( "$email" ,"Email From Customer",

"Message:<p> </p> $comment",

      "From: $email \nContent-Type: text/html; charset=iso-8859-1");

header ( "Location: thanks.html" );

 

mysql_close($con);//close connection

 

?>

 

</html>

 

<? ob_end_flush();?>

Link to comment
Share on other sites

<?php ob_start();?>

<html>

<?php

$con = mysql_connect("");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("shenmue232", $con);// database name

$result = mysql_query("SELECT * FROM tbl_emails");

$header = 'Content-Type: text/html; charset=iso-8859-1' . PHP_EOL;
while($row = mysql_fetch_array($result))
  {
  mail($row['email'],"Email From Customer","Message:<p> </p>" . $_POST['comment'], $header . 'From: ' $row['email'] . PHP_EOL);
  }

header ( "Location: thanks.html" );

mysql_close($con);//close connection

?>

</html>

<?php ob_end_flush();?>

Link to comment
Share on other sites

Hi i have made the changes to the code but i get this error message:

 

Parse error: syntax error, unexpected T_VARIABLE in /home/content/n/e/w/newman100/html/holmwoodlandscapes/sendmail.php on line 21

 

Here is the code so far:

 

<?php ob_start();?>

 

<html>

 

<?php

 

$con = mysql_connect("");//connect to server

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("shenmue232", $con);// database name

 

$result = mysql_query("SELECT * FROM tbl_emails WHERE email > 0");

echo mysql_num_rows($result);

 

$header = 'Content-Type: text/html; charset=iso-8859-1' . PHP_EOL;

while($row = mysql_fetch_array($result))

  {

  mail($row['email'],"Email From Customer","Message:<p> </p>" . $_POST['comment'], $header . 'From: ' $row['email'] . PHP_EOL);

  }

 

header ( "Location: thanks.html" );

 

mysql_close($con);//close connection

 

?>

 

</html>

 

<?php ob_end_flush();?>

 

Link to comment
Share on other sites

mail($row['email'],"Email From Customer","Message:<p> </p>" . $_POST['comment'], $header . 'From: ' $row['email'] . PHP_EOL);

 

missed out a concatenation!!!!

 

try this

 

mail($row['email'],"Email From Customer","Message:<p> </p>" . $_POST['comment'], $header . 'From: ' . $row['email'] . PHP_EOL);

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.