×

info

Dear guests,
You are currently on the old forum we kept as a knowledge base. You will find the new community forum here
Welcome, Guest
Username: Password: Remember me
Keyword

TOPIC: Personalized Emails to Ad Hoc List

Personalized Emails to Ad Hoc List 3 years 7 months ago #106544

  • Anonymous user
  • jimbrooking's Avatar
  • Posts: 91
  • Karma: 0
We have a subscription to ACYMailing Essentials. I have a problem that I would appreciate suggestions to solve. Or comments on my idea for solution. We are a homeowner association with about 1,500 member email addresses. Each year, in November, we send out a personalized email to each member that includes their current directory information: name, address and contact information. The PHP script I wrote to do this sends each email using the PHP mail() function through my hosting company's email server. The emails are sent out a few at a time to comply with the hosting company's terms of service. The problem is that a LOT of these messages - perhaps 10% are being rejected by various ISPs' spam filters for one reason or another. I have made repeated tweaks to our Joomla configuration at the suggestion of the hosting company, but an unacceptable number of these known-to-be-valid emails are still being rejected.

I notice that when we send messages out using ACYMailing (85 at a time, four times an hour to stay within the 500/hour ToS allowance) each group of 85 gets perhaps 15 failures, but ultimately, as far as I can tell, the failed attempts are retried until they succeed, so your methods are clearly superior to mine.

I would like to use ACYMailing's API to do something like send each personalized email to each of the 1,500 email addresses, a different message to each email, using the "Send a Newsletter to a Single User" API call.
  1. Will ACYMailing ensure that the list of 1500 is processed at the send rate in my ACYMailing configuration?
  2. Will there be a problem in creating 1,500 individual newsletters through the API? (I suppose they all have to remain in the newsletter list until all newsletters are sent?)
  3. Is there a better way?
Thanks for your help with your great product!
Jim Brooking
Please log in to post a reply

Personalized Emails to Ad Hoc List 3 years 7 months ago #106562

  • Tom
  • Tom's Avatar
  • Posts: 4581
  • Karma: 188
Hello,

1/ You can configure AcyMailing to send 85 email every 15 minutes: www.acyba.com/acymailing/116-acymailing-...cess.html#commercial

2/ 3/ How is your user data stored? You should only create one newsletter and use tags to load your data. This way, when sending AcyMailing will replace the tag by the receiver data.
For example {subtag:name} and {subtag:email} will be replaced by the name and email of the receiver.
We have integrations with other Joomla component to get data from them. You can find the list there: www.acyba.com/acymailing/plugins.html
We have a universal tag plugin that allows you top get data directly from a database: www.acyba.com/acymailing/plugins.html#universaltag
Using the Enterprise version of AcyMailing you could create custom fields to have your users specific data directly in AcyMailing: www.acyba.com/acymailing/8-acymailing/12...ng-customfields.html
Yes the newsletter must stay in the newsletter listing. If you delete it, the sending will be stopped.
Please log in to post a reply

Personalized Emails to Ad Hoc List 3 years 7 months ago #106605

  • Anonymous user
  • jimbrooking's Avatar
  • Posts: 91
  • Karma: 0
I have already configured ACYMiling to send 85 emails very 15 minutes, so that's not an issue.

I have attached a sample of the email I want to send out Note that
  1. The subject line contains personalized content
  2. The email "TO" address is, of course, personalized, and
  3. The circled (or "ellipsed") content is formatted (with CSS) personalized content

I have been using a PHP script that reads our directory database tables, constructs each email, and sends each of them to the intended recipient using PHP mail(), and does not require any Joomla code, plugins or otherwise.

The GUI nature of the Universal Tag plugin doesn't look like it will work, as the circled content is derived from two database tables and is formatted using some convoluted logic to place the individual data elements within.

It appears that one can create tags by direct calls using the API, but it also looks lihe this must be done within the context of a plugin, which is daunting to me, as I haven't written a plugin. If your sample plugin could be installed and work out of the box, perhaps I could construct the email with its customized fields using tags like "$email", "$address" and "$dirinfo", then use the API's acymailing_replaceusertags(&$email,&$user,$send=true) function to change each email and send them. Would that work, do you think?

Thanks.
Attachments:
Please log in to post a reply

Personalized Emails to Ad Hoc List 3 years 7 months ago #106633

  • Tom
  • Tom's Avatar
  • Posts: 4581
  • Karma: 188
The Universal tag plugin may not be the better solution indeed.

The solution would be to create your own tag plugin. This way with a tag you could get the data you want and customize it as you want.
Here is the documentation on how to create a tag plugin, with an example plugin (all the structure and default functions are there): www.acyba.com/acymailing/64-acymailing-d...cumentation.html#tag

Then when you create your newsletter you could use the tag inside.
But this will work only if you send using AcyMailing.
Please log in to post a reply

Personalized Emails to Ad Hoc List 3 years 7 months ago #106873

  • Anonymous user
  • jimbrooking's Avatar
  • Posts: 91
  • Karma: 0
I have started coding and immediately ran into a problem. The code in the ACYMailing API for Get a User Subscription includes the lines
// Get the subscriber ID (ID of the AcyMailing user) from his email address or his Joomla user ID
$userClass = acymailing_get('class.subscriber');
$subid = $userClass->subid($emailOrUserID);
Entering a valid Joomla user ID (for a subscriber) or email (for a subscriber) causes the page to stop execution, hung in some loop within $userClass->subid(). I would expect a valid subscriber ID would be returned for a valid subscriber identified by email or joomla ID, or a FALSE or 0 value if the jID or email is not known to ACYMailing. Is there some prerequisite code needed before the Get User Subscription code?

In context, my code is
                $userClass = acymailing_get('class.subscriber');
                echo (count($emailAry) . ' records in $mailAry<br />');
                for($ix=0; $ix<count($emailAry); $ix++) {
                    echo "$ix ";
                    $rec = $emailAry[$ix];
                    pr ($rec);
                    pr($rec['Email']);
                    die('255');
                    $subid = $userClass->subid($rec['Email']);
                    pr($subid);
                    if($debugging) {
                        if($subid) {
                            echo $rec['Email'] . " has ACYMailing id $subid<br />";
                            $emailAry[$ix]['ACYid'] = $subid;
                        }
                        else
                            echo  $rec['Email'] . " has no ACYMailing id<br />";
                    }
                    if($ix=9) break;
                }
which has a lot of debugging code in it (pr() and echo). The code up to and including die() statement immediately before the call to $userClass->subid() is executed as expected. Removing the die() statement causes the page to hang and time out.

(The include of helper.php is accomplished above the quoted code.)

The printout from the code with the die() statement is
1532 records in $mailAry
0
=====Debugging printout Called by require_once at line 253=====

Array(3)
(
|  ['ACYid']=String(0)""
|  ['Lot']=String(8)"GRA1K311"
|  ['Email']=String(21)"whaler2@earthlink.net"
)
=====End Debugging printout=====

=====Debugging printout Called by require_once at line 254=====

=String(21)"whaler2@earthlink.net"
=====End Debugging printout=====

255
Last Edit: 3 years 7 months ago by Anonymous user. Reason: Correct punctuation.
Please log in to post a reply

Personalized Emails to Ad Hoc List 3 years 7 months ago #106900

  • Alexandre
  • Alexandre's Avatar
  • Posts: 2462
  • Karma: 67
Hi,

I can't find the " $debugging " declaration.
So this could be the problem ;)
Last Edit: 3 years 7 months ago by Alexandre.
Please log in to post a reply

Personalized Emails to Ad Hoc List 3 years 7 months ago #106932

  • Anonymous user
  • jimbrooking's Avatar
  • Posts: 91
  • Karma: 0
See line 32 in the attached zip file. My initial post was a snippet of code where the problem apparently manifests itself.
Attachments:
Please log in to post a reply

Personalized Emails to Ad Hoc List 3 years 7 months ago #106941

  • Alexandre
  • Alexandre's Avatar
  • Posts: 2462
  • Karma: 67
Hi,

What's the result if you put this line :
die('Sub id is : '.$subid);

just after
$subid = $userClass->subid($rec['Email']);
?

Is the die() function well executed ?
Please log in to post a reply

Personalized Emails to Ad Hoc List 3 years 7 months ago #106945

  • Anonymous user
  • jimbrooking's Avatar
  • Posts: 91
  • Karma: 0
The problem is that when $userClass->subid() is called, there IS no return. The page load times out within the function call. So your suggested statement would never be executed.
Last Edit: 3 years 7 months ago by Anonymous user. Reason: Typo
Please log in to post a reply

Personalized Emails to Ad Hoc List 3 years 7 months ago #106964

  • Alexandre
  • Alexandre's Avatar
  • Posts: 2462
  • Karma: 67
Hi,

Did you try this ?
Does the function ends with a timeout ?
Do you get a blank page without any information ?
Is the display_errors set to Yes in your php.ini file ?
What's the value of the error_reporting option in your php.ini file ?

Here is the subid function
function subid($email){
		if(is_numeric($email)){
			$cond = ' userid = '.$email;
		}else{
			if(!empty($email) && version_compare(JVERSION, '3.1.2', '>=')) $email = JStringPunycode::emailToPunycode($email);
			$cond = 'email = '.$this->database->Quote(trim($email));
		}
		$this->database->setQuery('SELECT subid FROM '.acymailing_table('subscriber').' WHERE '.$cond);
		return $this->database->loadResult();
	}

As you can see there is always a result returned so the problem must come from something else.
Feel free to test it step by step in order to find the problem.

Also, I can't open your ZIP file..
Please log in to post a reply

Personalized Emails to Ad Hoc List 3 years 7 months ago #107082

  • Anonymous user
  • jimbrooking's Avatar
  • Posts: 91
  • Karma: 0
The ZIP file contents:
<?php
/* * *****************************************************************************
 *
 * /fhaphp/dirProof.php
 *
 * This script is called by Joomla article ID 1636.
 *
 * Accumulates a list of unique email addresses from the FHA directory (tblLotsX,
 * tblNamesX) and for each, invokes directory lookup server /code/dirServ.php
 * using an AJAX call to build an FHA directory entry associated with the residence
 * associated with the email.
 *
 * On command, a script called from this program will send out all emails with
 * associated directory information to its owner. THis page is used to get people
 * to check and verify the information in the emailed directory listing.
 *
 * Sending is throttled to 340/hour, or one every 2 seconds, to stay within the
 * limitations imposed by our hosting company (400/hour). The entire list, then,
 * requires about ___ hours to send all emails.
 *
 * Modified 12/2016 by Jim to use ACYMailing to send emails using FHA replacable 
 * strings (AYMailing Tags) within the message subject and body.
 *
 * ***************************************************************************** */

//	ID this Page

$PAGENAME = '/fhaphp/dirProof.php';
$PAGETITLE = 'Request Directory Verification';
$PROGERROR = '';        //      Set empty so doesn't throw an error.

$debugging = TRUE;              //  Can by used to control actions or debugging printouts
if ( !$debugging )
    ini_set('default_socket_timeout', 6000);

$document = & JFactory::getDocument();
$config = JFactory::getConfig();
$sitename = $config->get( 'sitename' );

$document->setTitle($sitename . " - " . $PAGETITLE);
// No mailcloak-off b/s Nonumber.nl's Email Protector is in.

echo("\n<input type='hidden' id='PAGENAME' value='$PAGENAME'>\n");    //So you can "View Source" in the browser and see who this is

require_once ($_SERVER["DOCUMENT_ROOT"] . "/code/funcPr.php"); // debug print fcn "pr"
require_once ($_SERVER["DOCUMENT_ROOT"] . "/code/funcIsAdmin.php"); // test for admin group membership

echo("<script type='text/javascript'>");
require_once ($_SERVER["DOCUMENT_ROOT"] . "/code/async/async.js");  //  from code.google.com
echo("</script>");
require_once ($_SERVER["DOCUMENT_ROOT"] . "/code/doAjax.php"); // FHA fcn to call ajax
/*
  foreach (array_keys($_GET) as $key)
  $$key = $_GET[$key];
 */
foreach (array_keys($_POST) as $key)
    $$key = $_POST[$key];

while (true) { /*  Provide an outer loop from which to "break;" to do a graceful
  way to end a PHP program and let Joomla finish painting the
  page.
  Remember to set $PROGERROR to an error message of you want it
  to be "echo'd" at exit */

//See http://docs.joomla.org/Accessing_the_current_user_object for reference
    $user = & JFactory::getUser();
    $userEmail = $user->email;
    $userName = $user->username;
    $logon = $user->name;
    $userid = $user->id;

    $privUser = isAdmin($userid, array('Super Users'));
    if (!$privUser) {
        $PROGERROR = "<p>You need to have privileges to use this page.</p>";
        break;
    }
    
    //  Load ACYMailing API Support; Eit with error if it won't load
    if(!include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acymailing'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php')){
        echo 'This code can not work without the AcyMailing Component';
        return false;
    }

    require ($_SERVER["DOCUMENT_ROOT"] . "/code/parms.php");

    $link = mysqli_init();
    $cn = mysqli_real_connect($link, $dbhost, $login, $pw, $db);
    if (!$cn) {
        $PROGERROR = "Could not connect to database : " . mysqli_connect_error();
        break;
    }

    $http = $_SERVER['HTTPS'] ? 'https' : 'http';
    $iAm = $http . "://" . $_SERVER['SERVER_NAME'];

    $delay = 10;        //  How many minutes to wait between batches
    $batchCount = 30;   //  Hou many emails in a batch (Depends on Hosting Co. ToS.
    $wait = (isset($repeat) && $repeat > 0) ? $delay * 60 * 1000 : 0;
    $GRText = <<<EOF
    <p style="color:red;font-weight:bold">
        Galloway Ridge Residents <u>must</u> acknowledge this email in order to retain their listing
        in the FHA Directory!
    </p>
    <p>
        If you do not want to be listed in the FHA Directory, just delete this email and <u>do not click</u> the acknowledgement below.
    </p>
    <p>If you want your directory information listed
        in the FHA Directory, Click the green box below that says "LIST ME IN THE FHA DIRECTORY".
    </p>
    <a href="%1">
        <div style="text-align:center;font-weight:bold;width:10em;background-color:lightgreen;border:2px solid darkgreen;border-radius:10px;padding 10px; margin:.5em auto;">
            LIST ME IN THE<br />
            FHA DIRECTORY
        </div>
    </a>
EOF;
    $FVText = <<<EOF
    <p>
        If this information is correct <a href="%1">please click here</a>
        to signify acceptance. (Clicking the link will provide you with
        a confirmation page.) No further action is needed.
    </p>
EOF;

/////////////////////TODO: Insert your script below this line///////////////////
    ?>

    <script type='text/javascript'>
        iAm = "<?= $iAm ?>";     // current web address (no trailing "/") for javascript to use
    </script>

    <style type='text/css'>
        .mybtn {
            display:block;
            margin: 1em auto 1em auto;
        }
        #mybtns {
            display:block;
            width:500px;
            border:1px lightgrey solid;
            margin: 1em auto 1em auto;
            padding: 1em;
        }
        .wrn {
            font-weight: bold;
            text-decoration: underline;
            font-style: italic;
        }
    </style>
    <script type='text/javascript'>
        var d=document;          //  convenience variable
        var wait = <?= $wait ?>;           //  If !== 0 recall this page after 'wait' minutes
        function subReset() {
            document.frm.action.value='rebuild';
            //  alert(document.frm.action.value);
            return true;
        }
        function subAll(rpt) {
            if(rpt===1) {
                wait = <?= $delay ?> * 60 * 1000;   //  20 minutes, in milliseconds
                document.frm.repeat.value='1';
            }
            document.frm.action.value='send';
            //  alert(document.frm.action.value);
            return true;
        }
    </script>
    <?php
    require_once $_SERVER["DOCUMENT_ROOT"] . '/code/funcDirServePROOF.php';    //  Makes a directory query
    require_once $_SERVER["DOCUMENT_ROOT"] . '/code/funcQryToArray.php';    //  Reads a query into an array

    $lotLimit = '242';                //  Send only to this lot's email address (for debugging)

    $tbl = 'tblDirCheckACY';               //  Database table used to feed this process

    $SQL = "SELECT
        count(`Lot`) as records
        FROM $tbl
        ;";
    $res = mysqli_query($link, $SQL);
    if (!res) {
        $PROGERROR = "Error reading database status.";
        break;
    }
    $line = mysqli_fetch_assoc($res);
    extract($line);
    $SQL = "SELECT
        count(`Sent`) as sent, max(`Sent`) as latest
        FROM $tbl
        WHERE `Sent`>0
        ;";
    $res = mysqli_query($link, $SQL);
    if (!res) {
        $PROGERROR = "Error reading database status.";
        break;
    }
    $line = mysqli_fetch_assoc($res);
    extract($line);
    //  if($debugging) pr($latest, "Latest sent from DB");
    $last = ($latest == 0) ? '' : " The last email sent went out at $latest.";
    if ($sent == $records)
        $sent = 'All';
    $sofar = ($sent == 'All') ? '' : ' so far';
    ?>
    <h3>Database Status - <?= date('m/d/Y H:i') ?></h3>
    There are currently <?= $records ?> records in the database table <?= $tbl ?>.
    <?= $sent ?> records have been sent<?= $sofar ?>.<?= $last ?>
    <p>

        <?php
        if ($debugging)
            echo("<p>DEBUGGING: Action:$action Repeat: $repeat</p>");
        switch ($action) {
            case 'rebuild':                       //  Rebuild Email table

                $sql = "DELETE FROM $tbl WHERE 1;";
                $res = mysqli_query($link, $sql);          //  Clean out table

               $SQL = "INSERT INTO $tbl (Lot, Email, Created, Sent, Acked, AckTF) "
                    . "SELECT n.Lot AS Lot, PEmail AS Email, NOW() AS Created, "
                    .   "NULL AS Sent, NULL AS Acked, Null AS AckTF FROM tblNamesX as n "
                    . "UNION ALL "
                    . "SELECT l.Lot AS Lot, HEmail AS Email, NOW() AS Created, "
                    .   "NULL AS Sent, NULL AS Acked, Null AS AckTF "
                    . "FROM  tblLotsX as l;";              //  SQL to build table
                if ($debugging)
                    echo("<p>SQL: $SQL</p>");
                $res = mysqli_query($link, $SQL);          //  Populate table
                if (!$res) {
                    $PROGERROR = "Error populating $tbl<br />$SQL<br />" . mysqli_error($link);
                    break 2;
                }
                echo("<p>Database successfully rebuilt from scratch.</p>");
                
                //  Update ACYMailing
                //  First, read in the emails we just saved from $table
                $SQL = "SELECT '' AS ACYid, Lot, Email FROM $tbl "
                        . "WHERE Email IS NOT NULL AND LENGTH(Email)>0 "
                        . "ORDER BY CAST(Lot AS UNSIGNED);"; // Read all email-bearing records
                $res = mysqli_query($link, $SQL);
                if (!$res) {
                    $PROGERROR = "Error reading $tbl<br />$SQL<br />" . mysqli_error($link);
                    break 2;
                }
                
                while(($emailAry[] = mysqli_fetch_assoc($res)) || array_pop($emailAry)); // Query into array
                
                $userClass = acymailing_get('class.subscriber');
                echo (count($emailAry) . ' records in $mailAry<br />');
                for($ix=0; $ix<count($emailAry); $ix++) {
                    echo "$ix ";
                    $rec = $emailAry[$ix];
                    pr ($rec);
                    pr($rec['Email']);
                    die('255');
                    $subid = $userClass->subid($rec['Email']);
                    //$subid = $userClass->subid($rec['Email']);
                    pr($subid);
                    if($debugging) {
                        if($subid) {
                            echo $rec['Email'] . " has ACYMailing id $subid<br />";
                            $emailAry[$ix]['ACYid'] = $subid;
                        }
                        else
                            echo  $rec['Email'] . " has no ACYMailing id<br />";
                    }
                    if($ix=9) break;
                }
                if(debugging)
                    pr($emailAry, 'After finding existing emails');
                
                break;
            case 'send':                                    //  Send Unsent, $batchCount per call

                $mailOK = $mailBAD = 0;
                if ($debugging)
                    $sqlLot = " AND c.Lot='$lotLimit'";
                else
                    $sqlLot = '';
                $srch = array('%1', '%2', '%3');
                $subject = "FHA Directory Verification ";
                if ($debugging)
                    $subject .= 'TESTING ';
                $additional = "MIME-Version: 1.0" . PHP_EOL;
                $additional .="Content-type: text/html; charset=iso-8859-1" . PHP_EOL;
                if($mailOK==0) $additional .= "Bcc:jim@jimbrooking.net" . PHP_EOL;
                $additional.= "From: FHA Directory Managers<directory@fearringtonfha.org>" . PHP_EOL;
                $additional.= "Reply-To: FHA Directory Managers<directory@fearringtonfha.org>";

                $msg = "
                <p>This email is sent to an address in your FHA Directory listing.
                If more than one person in your home has an email, each person will receive
                the same email. Only one resident needs to do anything with it.</p>
                <p>FHA has sent this out to ask that you check your directory
                information (below) and either correct it yourself using the
                FHA website or reply to this email and ask us to correct it for you.</p>
                <p>Your directory information is currently:</p>
                <span style=\"display:block;width:80%;border:1px solid lightgrey;background-color:#e0e0ff;padding:.5em;margin:.5em auto .5em auto;\">
                <table align=\"center\" cellspacing=\"5\">
                <tr>
                    <td valign=\"top\">%1</td>
                    <td valign=\"top\">%2</td>
                </tr>
                </table>
                </span>
                %3
                <p>If the information above is NOT correct, please
                <a href=\"http://www.fearringtonfha.org\">go to our website</a>,
                login with your valid username and password  and
                click \"Directory\" on the top menu, then click the \"Update Your Info\"
                link in the fourth line down. Or, if you prefer, just reply to
                this email (be sure to include the text of this email) and let us
                know what needs to be changed.</p>
                <p>A proof copy of the Residents Directory
                for Fearrington and Galloway Ridge residents will be available for
                your perusal at the FHA Office in the Gathering Place between November 14
                and November 23.</p>
                <p>Your response or corrective action should arrive by <u>November 24</u>
                to ensure the corrections appear in the 2017 FHA Directory and Handbook.</p>
                <p>We appreciate your patience and effort to help make the FHA directory as
                accurate as it can be.</p>
                <p align=\"right\" style=\"margin-right:2em;\">Thanks,<br>FHA Directory Management</p>
                ";

                $SQL = "SELECT DISTINCT
                Email, c.Lot, l.StreetNo, l.StreetName
            FROM
                $tbl as c
            INNER JOIN tblLotsX as l ON l.Lot=c.Lot
            WHERE
                Sent=0$sqlLot
            LIMIT
                $batchCount
            ;";
                if ($debugging)
                    echo("<p>SQL: $SQL</p>");
                $res = mysqli_query($link, $SQL);
                if (!$res) {
                    $PROGERROR = "Error in SQL reading database<br />$SQL<br />" . mysqli_error($link);
                    break 2;
                }
                $rows = mysqli_num_rows($res);
                if ($debugging) echo("<p>Rows Read: $rows</p>");
                if ($rows == 0) {
                    echo("<p>All emails have been sent.</p>");
                    break 2;
                } else {
                    $work = QryToArray($res);   //  All rows in $res to $work array
                    if($debugging) pr($work[0], "Work array[0]");
                    for ($i = 0; $i < $rows; $i++) {
                        extract($work[$i]);
                        if($debugging) pr($Lot,"Output for Lot $Lot");
                        $to = "Fearrington/Galloway Ridge Resident <$Email>";
                        $subj = "$subject - $StreetNo $StreetName";
                        if (($Lot !== $StreetNo) && (substr($Lot, 0, 1) !== ''))
                            $subj .= " (Lot $Lot)";
                        $more = $additional;
                        $where = "WHERE tblLotsX.Lot='$Lot' ";
                        unset($dirList);
                        $dirList = array();
                        if (!dirServe(true, $where, $dirList, false))
                            echo("<p>$where Entry not found</p>");   //  Get directory entry array
                        else {
                        if($debugging) pr($dirList, "Directory List for Lot $Lot");
                        unset($repl);
                        $ackPage = 'https://www.fearringtonfha.org/index.php?option=com_content&view=article&id=1637&Email=' . $Email . '&code=' . md5($Lot);
                        
                        // $sLot = $Lot;     //  uncomment 3 lines to see GR text
                        // $Lot = 'GR000000';

                        $txt = ( substr($Lot, 0, 2) === 'GR' )? $GRText : $FVText ;
                        
                        // $Lot = $sLot;
                        
                        $txt = str_replace( '%1', $ackPage, $txt);
                        if($debugging) pr($txt);
                        $repl = array(
                            $dirList[$Lot][1] . '<br />' . $dirList[$Lot][2],
                            $dirList[$Lot][3],
                            $txt
                        );
                        $msgOut = str_replace($srch, $repl, $msg);
                        if ($debugging) {
                            ?>
                        <h4>New Record <?= $i + 1 ?></h4>
                        <table border='1'>
                            <tr>
                                <td>
                                    To:
                                </td>
                                <td>
                                    "<?= htmlentities($to) ?>"
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Subject:
                                </td>
                                <td>
                                    "<?= $subj ?>"
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Body:
                                </td>
                                <td>
                                    "<?= $msgOut ?>"
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Addons:
                                </td>
                                <td>
                                    "<?= $additional ?>"
                                </td>
                            </tr>
                        </table>
                        <?php
                        $mailresult = mail($to, $subj, $msgOut, $additional);
                        if($debugging)
                            echo("<p><b>Time Sent: " . date('h:i:s') . "</b></p>\n");
                        if ($mailresult) {
                            $mailOK++;
                            echo('At' . date('h:i:s') . " Success mailing to $Email<br />");
                            $SQL = "UPDATE $tbl SET Sent=NOW() WHERE Lot='$Lot' AND Email='$Email';";
                            $res = mysqli_query($link, $SQL);
                            if(!$res) {
                                echo("<p>Error updating $tbl for Lot $Lot, email $Email<br />$SQL<br />" . mysqli_error($link) . "</p>");
                            }
                        } else {
                            $mailBAD++;
                            echo("FAIL mailing to $Email at Lot $Lot<br />");
                        }
                    } else {        //  Not debugging
                        $mailresult = mail($to, $subj, $msgOut, $additional);
                        if($debugging)
                            echo("<p><b>Time Sent: " . date('h:i:s') . "</b></p>\n");
                        if ($mailresult) {
                            $mailOK++;
                            echo('At' . date('h:i:s') . "Success mailing to $Email<br />");
                            $SQL = "UPDATE $tbl SET Sent=NOW() WHERE Lot='$Lot' AND Email='$Email';";
                            $res = mysqli_query($link, $SQL);
                            echo("$SQL<br />");
                            if(!$res) {
                                echo("<p>Error updating $tbl for Lot $Lot, email $Email<br />$SQL<br />" . mysqli_error($link) . "</p>");
                            }
                            if($res && (mysqli_affected_rows($link)==0)) echo("<p>No rows updated!</p>");
                        } else {
                            $mailBAD++;
                            echo("FAIL mailing to $Email<br />");
                        }
                    }
                    if($mailOK >= $batchCount) break;
                    }
                    if($debugging)
                        echo("<p><b>Time Sent: " . date('h:i:s') . "</b></p>\n");
                    sleep(2);       //  Wait 2 seconds between sends, else run afoul of ISP spam traps.
                }
            }
            echo("<p>Results: Successfully sent: $mailOK; FAILs: $mailBAD</p>");
            break;
        default:
            break;
    }
    ?>
    <div id="mybtns">
        <form name="frm" action="#" method="POST">
    <?php //if (($sent !== 'All')) { ?>
                <h3>Send a Batch</h3>
                <p>This will send a batch of <?= $batchCount ?> emails to the email addresses in the database.
                    Emails will be sent immediately in a batch. When each is sent, its send time
                    and success or failure will be recorded in its database record.</p>
                <input type="submit" value="Send a Batch" name='send1' class="mybtn" onClick="subAll(0);"/>
                <hr />
                <h3>Send All</h3>
                <p>This will send all unsent emails in batches of <?= $batchCount ?> emails each. After
                    each batch of emails is sent, the script will pause for <?= $delay ?> minutes before
                    sending another batch. This behavior is meant to keep FHA within the
                    limits of email sending imposed by the
                    Terms of Service of our hosting company, siteground.com.
                    If a batch had been
                    sent within <?= $delay ?> minutes of invoking this function, the script will wait
                    until <?= $delay ?> minutes has elapsed before sending its first batch.</p>
                <input type='submit' value="Send All" name="sendall" class="mybtn" onClick="subAll(1);" />
                <hr />
    <?php //} if (($sent <2) || ($sent == 'All')) { ?>
                <h3>Reset Database</h3>
                <p>This selection will erase all the existing email data, including records
                    of emails sent, responses, etc. There is no "undo" function. Once
                    this button is clicked, it's all gone. <span class="wrn">Caveat facitor!</span>
                    <!--Note that this button will not be visible unless NO records have
                    been sent or ALL records have been sent.-->
                    <input type="submit" value="Reset Database" name="init" class="mybtn" onClick="subReset();" />
    <?php //} ?>
                <input type='hidden' name="repeat" value="<?= $repeat ?>" />
                <input type="hidden" name='action' value='<?= $action ?>' />
        </form>
    </div>
    <?php
    if($debugging) {
        if(isset($action)) $m='is set and has value ' . $action . '.';
        else $m='is not set.';
        if(isset($wait)) $m .= ' $wait is set and has value ' . $wait . '.';
        echo("<p>After form generated: action " . $m);
    }
 ?>
        <script type='text/javascript'>
            if(('<?= $action ?>' == 'send') && (wait!==0)) {
                // alert("<?= $action ?>\n"+wait);
                intervalName = window.setInterval('document.frm.submit()', wait);
            }
        </script>
<?php

////////////////////////////Your script precedes this line//////////////////////
//////////////////////////////Gracefully exit, Provide a way to die quietly/////
    return;
}
/* if you break out if the while(true) loop and get here, I'll see if you had set
 * $PROGERROR and, if so, I'll echo it with <br>'s fore and aft, then return
 */
$PROGERRORbreaks = "<br />";
if ($PROGERROR <> "" || !isset($PROGERROR))
    echo($PROGERRORbreaks . $PROGERROR . $PROGERRORbreaks . 'Error from ' . $PAGENAME . $PROGERRORbreaks);
return;     //  Back to Joomla

The article that calls it consists of the following code, which is executed because of a plugin, "PHP Anywhere". Could also work with Sourcerer plugin.
<?php
error_reporting(E_ERROR | E_WARNING);
ini_set("display_errors", 1);
/* Front end for Directory Validation */
require_once($_SERVER["DOCUMENT_ROOT"] . "/fhaphp/dirProof_AM.php");
?>

I don't know what to do with your subid() code. I agree that it SEEMS to always return something unless one of the Joomla functions it depends on doesn't like what it sees. Nonetheless, a die() statement before the call to subid() always executes, and a die() statement after the call to subid() never executes, and for this case, the page load times out..
Please log in to post a reply

Personalized Emails to Ad Hoc List 3 years 7 months ago #107083

  • Anonymous user
  • jimbrooking's Avatar
  • Posts: 91
  • Karma: 0
Please drop this issue. I have found a problem in my code - unexpected input. I am sorry I have taken your time needlessly.
Please log in to post a reply

Personalized Emails to Ad Hoc List 3 years 7 months ago #107102

  • Alexandre
  • Alexandre's Avatar
  • Posts: 2462
  • Karma: 67
Hi,

No problem! You're welcome :)
Please log in to post a reply
Time to create page: 0.121 seconds
Powered by Kunena Forum