FRED™  3.0
FRED™: Framework for Rapid and Easy Development
Mail Class Reference
Inheritance diagram for Mail:
Component Thing

Public Member Functions

 filterRecipients ($recipients)
 Filter a list of recipients. More...
 
 message ($from=null, $to=null, $subject=null, $body=null, $html=false)
 Create a new Swift Mailer message object. More...
 
 mailer ($host=null)
 Domain specific mailer. More...
 
 send ($message)
 Send a message. More...
 
 queue ($message, $delay=0, $id=null)
 Add a message to the queue (with possible delay). More...
 
 delete ($id)
 Delete a message from the queue. More...
 
 spool ($time=null)
 Spool the message queue. More...
 
 box ($name=null)
 Open an IMAP mailbox. More...
 
 __invoke ($from=null, $to=null, $subject=null, $body=null, $html=false)
 
- Public Member Functions inherited from Component
 __construct ($fred, $config=null)
 
 __destruct ()
 
 clientConfig ()
 Public configuration. More...
 
 config ($key, $default=null)
 Retrieve a config value. More...
 
 ping ()
 Ping function. More...
 
 filemtime ($filename)
 Filemtime with session cache. More...
 
 component ($name)
 Get a component (local or default). More...
 
 components (... $names)
 Get multiple components in an array. More...
 
- Public Member Functions inherited from Thing
 propertyExists ($property)
 Check if a property exists (public or published). More...
 
 constants ($prefix=null)
 Return all constants. More...
 
 get ($key)
 Get one or more properties. More...
 
 set ($key, $value=null)
 Set one or more properties. More...
 
 __get ($key)
 
 __set ($key, $value)
 

Data Fields

 $defaultFrom = null
 
 $restrict = []
 Regular expressions that the e-mail address has to match (at least one; empty = allow all). More...
 
 $mailers = []
 Domain specific mailer/transport (key = domain name; value = array with mailer or host, port,. More...
 
 $subjectId = '*Subject'
 Get subject from translation component (when body is array of tags); asterisk is. More...
 
 $bodyId = '*Message'
 Get message body from translation component (when body is array of tags); asterisk is. More...
 
 $markup = ['b' => '*'
 
 $dataPrefix = 'data-'
 Prefix for data tags (empty = do not allow). More...
 
 $imageExtMask = '(gif|jpe?g|png|svg)'
 Allowed file extensions for (local) embedable images. More...
 
 $attachmentExtMask = '(docx?|pdf|txt|xlsx?)'
 Allowed file extensions for (local) attachments. More...
 
 $forward = []
 Forwarding rules (array of records with regex for from, to, cc, bcc, subject, and/or body; if all. More...
 
- Data Fields inherited from Component
 $filemtimeTtl = 0
 
- Data Fields inherited from Thing
const HIDDEN = 0
 Property is hidden. More...
 
const READABLE = 1
 Property is readable. More...
 
const WRITEABLE = 2
 Property is writeable. More...
 
const READWRITE = 3
 Property is readable and writeable. More...
 

Protected Member Functions

 init ()
 
 log ($message, $result, $failures=null, $context=null)
 Add a sent message to the log. More...
 
 validFilename ($filename, $ext)
 Check if a filename is valid (external or in document root). More...
 
 dataTags ($body, $data, $tag=null)
 Find all tags with a certain data tag. More...
 
 textBody ($body)
 Remove all tags from the message body. More...
 
 htmlBody ($body, $message)
 Process HTML body. More...
 
 getImap ()
 
 getMailer ()
 
 getTransport ()
 
 getQueue ()
 
- Protected Member Functions inherited from Component
 init ()
 
 done ()
 
 getSession ()
 
- Protected Member Functions inherited from Thing
 publish ($property, $visibility=self::READABLE)
 Publish a property (or hide it again). More...
 
 configure ($config)
 Configure the object. More...
 
 _get ($key)
 Default getter if no specific setter is defined, and the property is also not published (readable). More...
 
 _set ($key, $value)
 Default setter if no specific setter is defined, and the property is also not published (writeable). More...
 

Protected Attributes

 $_mailer = null
 
 $_logger = null
 
 $_transport = null
 
 $_imap = null
 
 $_queue = null
 
- Protected Attributes inherited from Component
 $_fred = null
 
 $_config = null
 
 $_name = null
 
 $_components = []
 Local components (key = component name, value = component). More...
 
 $_session = null
 
- Protected Attributes inherited from Thing
 $_published = []
 Published properties (key = name of property, value = visibility). More...
 

Detailed Description

Definition at line 5 of file Mail.php.

Member Function Documentation

◆ __invoke()

__invoke (   $from = null,
  $to = null,
  $subject = null,
  $body = null,
  $html = false 
)

Definition at line 328 of file Mail.php.

◆ box()

box (   $name = null)

Open an IMAP mailbox.

Parameters
string$nameMailbox to connect to (empty = default).
Returns
\Rsi\Imap\Mailbox

Definition at line 277 of file Mail.php.

◆ dataTags()

dataTags (   $body,
  $data,
  $tag = null 
)
protected

Find all tags with a certain data tag.

Parameters
string$bodyHTML message body.
string$dataData tag to look for (without prefix).
string$tagHTML tag.
Returns
array Array with matches (full tags).

Definition at line 79 of file Mail.php.

◆ delete()

delete (   $id)

Delete a message from the queue.

Parameters
string$idMessage ID.
Returns
bool True if the message was deleted.

Definition at line 236 of file Mail.php.

◆ filterRecipients()

filterRecipients (   $recipients)

Filter a list of recipients.

Parameters
array$recipientsA list of recipients.
Returns
array Filtered list of recipients (only those matched by the restriction set, or all if no restrictions).

Definition at line 37 of file Mail.php.

◆ getImap()

getImap ( )
protected

Definition at line 281 of file Mail.php.

◆ getMailer()

getMailer ( )
protected

Definition at line 289 of file Mail.php.

◆ getQueue()

getQueue ( )
protected

Definition at line 317 of file Mail.php.

◆ getTransport()

getTransport ( )
protected

Definition at line 299 of file Mail.php.

◆ htmlBody()

htmlBody (   $body,
  $message 
)
protected

Process HTML body.

Parameters
string$bodyMessage in HTML format.
\\Swift_Message$messageSwift Mailer message object.
Returns
string Message in HTML format.

Definition at line 103 of file Mail.php.

◆ init()

init ( )
protected

Definition at line 28 of file Mail.php.

◆ log()

log (   $message,
  $result,
  $failures = null,
  $context = null 
)
protected

Add a sent message to the log.

Parameters
\\Swift_Message$message
int$resultResult from the send function.
array$failuresAddresses that failed.
array$contextExtra context for the log message.

Definition at line 56 of file Mail.php.

◆ mailer()

mailer (   $host = null)

Domain specific mailer.

Parameters
string$hostHost name of the sender.
Returns
\Swift_MailTransport Specific mailer, or default mailer.

Definition at line 172 of file Mail.php.

◆ message()

message (   $from = null,
  $to = null,
  $subject = null,
  $body = null,
  $html = false 
)

Create a new Swift Mailer message object.

Parameters
mixed$fromSender address (defaultFrom or ini sendmail_from when empty).
mixed$toRecipient(s).
string$subjectSubject line, or translation ID when the body is an array.
string | array$bodyMessage body, or translation tags.
bool$htmlTrue when the message body is in HTML format.
Returns
\Swift_Message

Definition at line 151 of file Mail.php.

◆ queue()

queue (   $message,
  $delay = 0,
  $id = null 
)

Add a message to the queue (with possible delay).

Note: requires the calling of spool() on a regular interval.

Parameters
\\Swift_Message$message
int$delayDelay in seconds.
string$idID for the message (if two messages have the same ID, the previous one is overwritten; empty = random).
Returns
bool ID when added to the queue successfully, false on failure.

Definition at line 219 of file Mail.php.

◆ send()

send (   $message)

Send a message.

If the message is not an object, it is created from all the parameters.

See also
message()
Parameters
\\Swift_Message$message
Returns
int Number of addresses that succeeded.

Definition at line 190 of file Mail.php.

◆ spool()

spool (   $time = null)

Spool the message queue.

Parameters
int$timeMaximum execution time (seconds; empty = unlimited).
Returns
int Number of sent messages.

Definition at line 244 of file Mail.php.

◆ textBody()

textBody (   $body)
protected

Remove all tags from the message body.

Link addresses are placed between parenthesis after the original anchor text.

Parameters
string$bodyMessage in HTML format.
Returns
string Message in plain text.

Definition at line 88 of file Mail.php.

◆ validFilename()

validFilename (   $filename,
  $ext 
)
protected

Check if a filename is valid (external or in document root).

Parameters
string$filename
string$extAllowed extension (local file only).
Returns
bool True when valid.

Definition at line 67 of file Mail.php.

Field Documentation

◆ $_imap

$_imap = null
protected

Definition at line 25 of file Mail.php.

◆ $_logger

$_logger = null
protected

Definition at line 23 of file Mail.php.

◆ $_mailer

$_mailer = null
protected

Definition at line 22 of file Mail.php.

◆ $_queue

$_queue = null
protected

Definition at line 26 of file Mail.php.

◆ $_transport

$_transport = null
protected

Definition at line 24 of file Mail.php.

◆ $attachmentExtMask

$attachmentExtMask = '(docx?|pdf|txt|xlsx?)'

Allowed file extensions for (local) attachments.

Definition at line 18 of file Mail.php.

◆ $bodyId

$bodyId = '*Message'

Get message body from translation component (when body is array of tags); asterisk is.

Definition at line 13 of file Mail.php.

◆ $dataPrefix

$dataPrefix = 'data-'

Prefix for data tags (empty = do not allow).

Definition at line 16 of file Mail.php.

◆ $defaultFrom

$defaultFrom = null

Definition at line 7 of file Mail.php.

◆ $forward

$forward = []

Forwarding rules (array of records with regex for from, to, cc, bcc, subject, and/or body; if all.

Definition at line 19 of file Mail.php.

◆ $imageExtMask

$imageExtMask = '(gif|jpe?g|png|svg)'

Allowed file extensions for (local) embedable images.

Definition at line 17 of file Mail.php.

◆ $mailers

$mailers = []

Domain specific mailer/transport (key = domain name; value = array with mailer or host, port,.

Definition at line 9 of file Mail.php.

◆ $markup

$markup = ['b' => '*'

Definition at line 15 of file Mail.php.

◆ $restrict

$restrict = []

Regular expressions that the e-mail address has to match (at least one; empty = allow all).

Definition at line 8 of file Mail.php.

◆ $subjectId

$subjectId = '*Subject'

Get subject from translation component (when body is array of tags); asterisk is.

Definition at line 11 of file Mail.php.


The documentation for this class was generated from the following file: