<?php

date_default_timezone_set('Europe/London');

require_once 'config.inc.php';
require_once 'MailManager.php';

try
{
  $mm = new MailManager($database_host, $database_user, $database_pass, $database_name);
  $mm->addRecipient('test@example.org');
}
catch (Exception $e)
{
  print $e->getMessage() . "\n";
}

try
{
  $mm = new MailManager($database_host, $database_user, $database_pass, $database_name);
  $mm->addRecipient('doesnotexist@manchester.ac.uk');
  $mm->addRecipient('doesnotexist@manchester.ac.uk');
  $mm->addRecipient('doesnotexist@manchester.ac.uk');
  $mm->addRecipient('doesnotexist@manchester.ac.uk');
  $mm->addRecipient('doesnotexist@manchester.ac.uk');
  $mm->addRecipient('doesnotexist@manchester.ac.uk');
  $mm->addRecipient('doesnotexist@manchester.ac.uk');
  
  $mm->send();
}
catch (Exception $e)
{
  print $e->getMessage() . "\n";
}
<?php

date_default_timezone_set('Europe/London');

require_once 'config.inc.php';
require_once 'MailManager.php';

// Recipient not in list of permitted domains
try
{
  $mm = new MailManager($database_host, $database_user, $database_pass, $database_name);
  $mm->addRecipient('test@example.org');
}
catch (Exception $e)
{
  print $e->getMessage() . "\n";
}

// Too many recipients
try
{
  $mm = new MailManager($database_host, $database_user, $database_pass, $database_name);
  
  $mm->setSubject('Test');
  $mm->setBody('Body');
  
  $mm->addRecipient('doesnotexist@manchester.ac.uk');
  $mm->addRecipient('doesnotexist@manchester.ac.uk');
  $mm->addRecipient('doesnotexist@manchester.ac.uk');
  $mm->addRecipient('doesnotexist@manchester.ac.uk');
  $mm->addRecipient('doesnotexist@manchester.ac.uk');
  $mm->addRecipient('doesnotexist@manchester.ac.uk');
  $mm->addRecipient('doesnotexist@manchester.ac.uk');
  
  $mm->send();
}
catch (Exception $e)
{
  print $e->getMessage() . "\n";
}
Set subject and body in 'too many recipients' test
Set subject and body in 'too many recipients' test

Subject and body are tested first, so if they are not set the 'too many
recipients' exception will never be triggered.
