Overview
  • Package
  • Class
  • Tree
  • Todo

Packages

  • AddonValue
    • Interfaces
  • ApiV2Controllers
  • Category
    • Collections
    • Entities
    • Factories
    • Interfaces
    • Providers
    • Repositories
    • Storages
  • Customer
    • Address
    • Country
    • CountryZone
    • Interfaces
    • Validation
    • ValueObjects
  • Email
    • Collections
    • Entities
    • Exceptions
    • Interfaces
    • Repository
    • ValueObjects
  • Http
    • Collections
    • Exceptions
    • Factories
    • Interfaces
    • ValueObjects
  • Loaders
    • CrossCuttingLoader
    • GXCoreLoader
    • Interfaces
  • None
  • Order
    • Collections
    • Entities
    • Factories
    • Interfaces
    • Repositories
    • Storages
    • ValueObjects
  • Product
    • Collections
    • Entities
    • Factories
    • Interfaces
    • Providers
    • Repositories
    • Storages
  • ProductModule
    • Collections
    • Deleter
    • Entities
    • Factories
    • Interface
    • Interfaces
    • Reader
    • Repositories
    • Writer
  • Shared
    • Exceptions
    • FileSystem
    • Interfaces
    • Storage
    • Types
  • Statistics
    • Interfaces
  • UserConfiguration
    • Interfaces
    • Repository

Classes

  • AttachmentsHandler
  • EmailFactory
  • EmailService
  • MailerAdapter

Class EmailService

Class EmailService

Represents the public API for the Email service of the system. External users must use this class for all the email operations except.

Important: Since the attachments will be flat-stored in the "uploads/attachmetns" directory the "send" and "queue" method will have to perform multiple writes to the database in order to get robust attachment handling that will not crash the rest of the service.

EmailService implements EmailServiceInterface
Package: Email
Category: System
Located at SystemServices/Email/EmailService.inc.php

Methods summary

public
# __construct( EmailRepositoryInterface $repository, EmailFactoryInterface $factory, MailerAdapterInterface $mailerAdapter, AttachmentsHandlerInterface $attachmentsHandler )

Class Constructor

Class Constructor

Parameters

$repository
E-Mail repository.
$factory
E-Mail factory.
$mailerAdapter
Mailer adapter.
$attachmentsHandler
E-Mail attachments handler.
public EmailInterface
# create( EmailContactInterface $sender, EmailContactInterface $recipient, EmailSubjectInterface $subject, EmailContentInterface $content = null )

Creates a new email

Creates a new email

Use this method to can a valid email object that can be sent without any additional modification. Optionally you can add more information to the email object such as attachments, BCC & CC contacts etc.

Parameters

$sender
Contains the sender information.
$recipient
Contains the recipient information.
$subject
Email record subject.
$content
(optional) Html content of the email.

Returns

EmailInterface
Valid email.

Implementation of

EmailServiceInterface::create()
public
# send( EmailInterface $email )

Sends and saves an email.

Sends and saves an email.

Parameters

$email
Contains email information.

Implementation of

EmailServiceInterface::send()
public
# queue( EmailInterface $email )

Saves an email as pending (will not be sent).

Saves an email as pending (will not be sent).

Parameters

$email
Contains email information.

Implementation of

EmailServiceInterface::queue()
public
# write( EmailInterface $email )

Writes an email instance to the DB.

Writes an email instance to the DB.

This method will store an email entity just the way it is without modifying other properties like the "send" or "queue" methods do. If you use this method or the "writeCollection" make sure that all the email properties are the desired ones.

Parameters

$email
Email to write.

Implementation of

EmailServiceInterface::write()
public EmailInterface
# getById( IdType $id )

Returns an email by id.

Returns an email by id.

Parameters

$id
The database ID that matches the email record.

Returns

EmailInterface
Contains the email information.

Implementation of

EmailServiceInterface::getById()
public EmailInterface|null
# findById( IdType $id )

Finds an email by ID.

Finds an email by ID.

Parameters

$id
The record ID that matches the email.

Returns

EmailInterface|null
Email or null if not found.

Implementation of

EmailServiceInterface::findById()
public
# delete( EmailInterface $email )

Removes an email from the database.

Removes an email from the database.

Parameters

$email
Contains the email information.

Implementation of

EmailServiceInterface::delete()
public EmailCollection
# filter( string $p_keyword, array $limit = array(), array $order = array() )

Filters email records with provided keyword string.

Filters email records with provided keyword string.

Parameters

$p_keyword
String to be used for filtering the email records.
$limit

(optional) Array that contains LIMIT and OFFSET value e.g. array( 'limit' => 10, 'offset' => 5 )

$order

(optional) Contains arrays with column, direction pairs e.g. array( 'column' => 'direction' )

Returns

EmailCollection
Email collection containing the email records.

Implementation of

EmailServiceInterface::filter()
public boolean
# validateEmailAddress( string $p_emailAddress )

Validate a string email address.

Validate a string email address.

Parameters

$p_emailAddress
Email address to be validated.

Returns

boolean
Returns the validation result (true for success, false for failure).

Throws

InvalidArgumentException
If argument is not a string.

Implementation of

EmailServiceInterface::validateEmailAddress()
public
# sendPending( )

Sends pending email records.

Sends pending email records.

Implementation of

EmailServiceInterface::sendPending()
public EmailCollectionInterface
# getPending( )

Return pending email records as an email collection.

Return pending email records as an email collection.

Returns

EmailCollectionInterface
The pending emails.

Implementation of

EmailServiceInterface::getPending()
public EmailCollectionInterface
# getSent( )

Returns sent email records as an email collection.

Returns sent email records as an email collection.

Returns

EmailCollectionInterface
Sent email records.

Implementation of

EmailServiceInterface::getSent()
public EmailCollection
# getAll( )

Returns all email records from the database.

Returns all email records from the database.

Returns

EmailCollection
Email records.

Implementation of

EmailServiceInterface::getAll()
public
# sendCollection( EmailCollectionInterface $collection )

Sends a collection of emails.

Sends a collection of emails.

Parameters

$collection
Email collection to send.

Implementation of

EmailServiceInterface::sendCollection()
public
# queueCollection( EmailCollectionInterface $collection )

Queues a collection of emails.

Queues a collection of emails.

Parameters

$collection
Email collection to queue.

Implementation of

EmailServiceInterface::queueCollection()
public
# writeCollection( EmailCollectionInterface $collection )

Writes a collection of emails into database.

Writes a collection of emails into database.

Parameters

$collection
Email collection to write.

Implementation of

EmailServiceInterface::writeCollection()
public
# deleteCollection( EmailCollectionInterface $collection )

Deletes a collection of emails.

Deletes a collection of emails.

Parameters

$collection
Email collection to delete.

Implementation of

EmailServiceInterface::deleteCollection()
public integer
# getRecordCount( string $p_filterKeyword = '' )

Returns the current count of the email records in the database.

Returns the current count of the email records in the database.

Parameters

$p_filterKeyword
(optional) If provided the records will be filtered.

Returns

integer
The row number of the email table.

Implementation of

EmailServiceInterface::getRecordCount()

Properties summary

protected EmailRepositoryInterface $repository

E-Mail repository.

E-Mail repository.

#
protected MailerAdapterInterface $mailerAdapter

Mailer adapter.

Mailer adapter.

#
protected EmailFactoryInterface $factory

E-Mail factory.

E-Mail factory.

#
protected AttachmentsHandlerInterface $attachmentsHandler

E-Mail attachments handler.

E-Mail attachments handler.

#
API documentation generated by ApiGen