DownloadMail Confirmation

4 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: July 7, 2016   (RSS)

By Perchpole - July 4, 2016

Hello, All -

I would like to add a very basic confirmation email to the DownloadMail plugin. My current set-up allows people to send in messages to CMSB via a special email address. The address is not hooked up to any kind of email client - so the only way I will know if an email has been received/processed is if I can get the DownloadMail plugin to tell me.

I assume it would only need a simple phpMail() instruction slipping into the code somewhere - but where?!

Thanks in advance for your help.

Perchpole

By Daryl - July 6, 2016

Hi Perch,

If I understand your requirement correctly, you can send yourself an email confirmation that the DownloadMail plugin downloaded/processed the emails by calling sendMessage() function inside the downloadMail_startTask() function after the downloadMail_checkAccounts() function is called.

For example:

function downloadMail_startTask() {
  // ... codes cropped
  
  // download mail
  $debugOutput  = true; // set to true to see program output
  list($countDownloaded, $countRemaining) = downloadMail_checkAccounts($debugOutput);
  
  if ($countDownloaded != 0 && $countDownloaded == $countRemaining){
    $errors = sendMessage(array(
      'from'    => "from@example.com",
      'to'      => "to@example.com",
      'subject' => "Finished downloading emails!",
      'text'    => "Text message content",
    ));
  }
  
  // .. codes cropped
}

The example code will check send an email to to@example.com if there were emails downloaded and if all the emails has been downloaded (downloaded == remaining)

I haven't tested this code so let us know if it worked on your set up.

Additionally, when you upgrade the plugin, the code will get overwritten so you will need to copy it over to the new version of the plugin.

Cheers,

Daryl Maximo
PHP Programmer - interactivetools.com

By Daryl - July 7, 2016

Hi Perch,

I was looking at our version that's not released yet.

For v1.01, you can insert the code in downloadMail_checkAccounts() function, on top of the "return array($countDownloaded, $countRemaining);" line.

Daryl Maximo
PHP Programmer - interactivetools.com