Amiro.CMS API Reference
Amiro.Ru / Manual
Loading search...

The AMI_MailQueue class

• Introduction

Class AMI_MailQueue.

• Class synopsis

AMI_MailQueue {
/* Methods */
// Constructor.
public __construct ( ) returns AMI_MailQueue;
// Create background process for the mail queue.
public addBackgroundProcess ( [ bool $run = FALSE ] ) returns AMI_MailQueue;
// Add e-mail into the queue.
public addMail ( AMI_Mail $oMail, array $aRecipients ) returns AMI_MailQueue;
}

• Class Details

Allows to add e-mails into the queue and send in background.
  Example:
  •  $AMI_ENV_SETTINGS array('mode' => 'full''disable_cache' => true);
  •  require 'ami_env.php';
  •  
  •  $oResponse AMI::getSingleton('response');
  •  $oResponse->start();
  •  
  •  // Create AMI_Mail object
  •  $oMail new AMI_Mail('from@domain.name''Email subject''Email body');
  •  
  •  // Create array of recipients
  •  $aRecipients array(
  •      'user1@domain.name' => array('greeting' => 'Mr.''username' => 'Name1'),
  •      'user2@domain.name' => array('greeting' => 'Ms.''username' => 'Name2')
  •  );
  •  
  •  // The fields in double pluses (++greeting++, ++username++) will be replaced with a user data from $aRecipients array
  •  $oMail->body 'Hello, ++greeting++ ++username++';
  •  
  •  // Create AMI_MailQueue object
  •  $oMailQueue new AMI_MailQueue();
  •  
  •  // Add AMI_Mail object into the queue
  •  $oMailQueue->addMail($oMail$aRecipients);
  •  
  •  // Add background process for sending e-mails in queue
  •  $oMailQueue->addBackgroundProcess();
  •  
  •  $oResponse->write('The e-mail was added into the queue for sending in background.');
  •  $oResponse->send();
Tags:
since 6.0.6

• Class Methods

// Constructor.
public __construct ( ) returns AMI_MailQueue;
// Create background process for the mail queue.
public addBackgroundProcess ( [ bool $run = FALSE ] ) returns AMI_MailQueue;
  • bool $run
    Instant run added process
// Add e-mail into the queue.
public addMail ( AMI_Mail $oMail, array $aRecipients ) returns AMI_MailQueue;
  • AMI_Mail $oMail
    AMI_Mail object
  • array $aRecipients
    Contains e-mails as keys and arrays of data to replace in letter