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
https://forums.phpfreaks.com/topic/67325-database-mail/
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
https://forums.phpfreaks.com/topic/67325-database-mail/#findComment-337775
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
https://forums.phpfreaks.com/topic/67325-database-mail/#findComment-338706
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
https://forums.phpfreaks.com/topic/67325-database-mail/#findComment-340160
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.