i want to retrive emails adds from db and i want to send one email to all of them ..it retrives emails from the data base but i want to to send mail to all the email adresses it retrives but it doesnt send it to all rather it sends the mail to the last one email address.please tell me whats wrong here.
<?php
require ('C:\wamp\bin\php\php5.2.6\PEAR\Mail.php');
require ('C:\wamp\bin\php\php5.2.6\PEAR\Mail\mime.php');
//require_once('auth.php');
include("conn.php");
$sql="SELECT * FROM emails ";
$result = connect($sql);
while($row = mysql_fetch_array($result)){
$email= $row['email_add'];
echo $email;
}
//
$sender = "abc@gmail.com"; // Your email address
//$recipient ="xyz@yahoo.com, abbc@hotmail.com";
$recipient = $email;
//$recipient = $_REQUEST['email']; // The Recipients name and email address
$subject ="Machines Error Report"; // Subject for the email
$text = 'This is a text message.'; // Text version of the email
//$date=$_REQUEST['AnotherDate'];
$abc=$_REQUEST['messag'];
//$subject=$_REQUEST['Subject'];
$mac=$_REQUEST['machine'];
$today = date("F j, Y, g:i a");
help with this code
Moderator: General Moderators
Re: help with this code
Here's your code with proper tags for posting (see the instuctions about posting for info)
ok now you'll see line 16 is the end of your while loop, so it loops through all your data first then exits the while loop and only runs the following send mail part once on the last item.
Code: Select all
<?php
require ('C:\wamp\bin\php\php5.2.6\PEAR\Mail.php');
require ('C:\wamp\bin\php\php5.2.6\PEAR\Mail\mime.php');
//require_once('auth.php');
include("conn.php");
$sql="SELECT * FROM emails ";
$result = connect($sql);
while($row = mysql_fetch_array($result)){
$email= $row['email_add'];
echo $email;
}
//
$sender = "abc@gmail.com"; // Your email address
//$recipient ="xyz@yahoo.com, abbc@hotmail.com";
$recipient = $email;
//$recipient = $_REQUEST['email']; // The Recipients name and email address
$subject ="Machines Error Report"; // Subject for the email
$text = 'This is a text message.'; // Text version of the email
//$date=$_REQUEST['AnotherDate'];
$abc=$_REQUEST['messag'];
//$subject=$_REQUEST['Subject'];
$mac=$_REQUEST['machine'];
$today = date("F j, Y, g:i a");
Re: help with this code
hay tahnx for the help..
and i am sorry enxt time i wil read the rules for posting i joined the forum today and just posted the question.. am sorry fro that..
thanx again
take care
and i am sorry enxt time i wil read the rules for posting i joined the forum today and just posted the question.. am sorry fro that..
thanx again
take care
Re: help with this code
Happy to help. Misplaced brackets are a pain.