I want to perform the following steps.
Step 1: get the communication records from the database whose time has been reached.
Step 2: run the loop of above and get the email addresses.
Step 3: run the loop of email addresses and send emails.
This is my php script.
Code: Select all
<?php
include('iSDK/src/isdk.php');
$myApp = new iSDK();
// Test Connnection
if ($myApp->cfgCon("connectionName")) {
echo "Connected...";
} else {
echo "Not Connected...";
}
$query = mysql_query('SELECT * FROM emails where senddate <= NOW() AND STATUS = "pending"');
$emailaddress= array();
while ($result = mysql_fetch_assoc($query))
{
$emailaddress[] = $result['email'];
$count = mysql_num_rows($query);
if($result)
{
for($i=0; $i<$count; $i++){
$conDat = array('Email' => $emailaddress[$i]);
$conID = $myApp->addCon($conDat);
$clist = array($conID);
$email = $myApp->sendEmail($clist, 'sender@example.com', '~Contact.Email~', 'ccAddresses', 'bccAddresses', 'contentType', 'Subject', 'htmlBody', 'txtBody');
}
}
}
?>