Jump to content

Recommended Posts

I would like to send an email when % is >than 50%, if so get fields from Txt fiel and fields from DB and send an email to the address in the txt file. 

 <html>
<head><title>Email Alert</title></head>
<body>
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;

//$mail->SMTPDebug = 3;                               // Enable verbose debug output
mysql_connect("ip","user","pass") or die(mysql_error());
//mysql_select_db("DB") or die(mysql_error());
//$sql = "SELECT * from pool";



$sql = mysql_db_query ("demo", "select * from pool ");
while ($row = mysql_fetch_assoc($sql)) {
$sql = "SELECT '%' FROM pool Where >= 50 ";
{   
    //echo $row->number;

    $percent = $row['%'] ;
    $pool2 = $row['pool'];
    $balance = $row['balance'];
   


///////////////////////////
//data from file //////////
//////////////////////////   

$file = fopen('EmailAndPool2.csv', 'r');
$fields = array();

if ($file) {
    while (($data = fgetcsv($file)) !== false) {
     

        if(empty($fields)) {
            $fields = $data;
            continue;
        }

      
        $row = array_combine($fields, $data);

        // Format output conveniently with sprintf
        $output = sprintf("%s Pool %s email.\n",
                          $row['pool'],
                          $row['email']);
        echo $output;
    }
    fclose($file);

$pool1 = $row['pool'];

//while ($pool2 == $pool1 and $percent > "50")

$pool2 =$row['pool2'];
$mail = new PHPMailer;
$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'xxxxxxxxx;  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'xxxxxxxxxxxxxxxxx';                 // SMTP username
$mail->Password = 'xxxxxxxxxxxxxxxx;                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                                    // TCP port to connect to

$mail->FromName = 'Support';
$mail->addAddress ($row['email']);
//$mail->addAddress = $members;
//$mail->addCC('xxxxxxxxxxx'); 
//$mail->addCC('xxxxxxxxxxxxxxxx'); 
$mail->WordWrap = 50;                                 // Set word wrap to 50 characters

$mail->isHTML(true);     
$mail->Subject = 'test';
$mail->Body    = 'test ';
$email_from = 'xxxxxxxxxxxx';


}
if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}
}
}

?>

    </body>
</html>

Thank you 

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.