PHP Class Contao\Email

The class functions as an adapter for the Swift mailer framework. It can be used to send e-mails via the PHP mail function or an SMTP server. Usage: $email = new Email(); $email->subject = 'Hello'; $email->text = 'Is it me you are looking for?'; $email->sendTo('[email protected]');
Datei anzeigen Open project: contao/core-bundle Class Usage Examples

Protected Properties

Property Type Description
$arrFailures array Invalid addresses
$blnEmbedImages boolean Embed images
$intPriority integer E-mail priority
$objMessage Swift_Message Message object
$strCharset string Character set
$strHtml string HTML part of the e-mail
$strImageDir string Image directory
$strLogFile string Log file name
$strSender string Sender e-mail address
$strSenderName string Sender name
$strSubject string E-mail subject
$strText string Text part of the e-mail

Public Methods

Method Description
__construct ( ) Instantiate the object and load the mailer framework
__get ( string $strKey ) : mixed Return an object property
__set ( string $strKey, mixed $varValue ) Set an object property
addHeader ( string $strKey, string $strValue ) Add a custom text header
attachFile ( string $strFile, string $strMime = 'application/octet-stream' ) Attach a file
attachFileFromString ( string $strContent, string $strFilename, string $strMime = 'application/octet-stream' ) Attach a file from a string
hasFailures ( ) : boolean Return true if there are failures
replyTo ( ) Add ReplyTo e-mail addresses
sendBcc ( ) Add BCC e-mail addresses
sendCc ( ) Add CC e-mail addresses
sendTo ( ) : boolean Send the e-mail

Protected Methods

Method Description
compileRecipients ( array $arrRecipients ) : array Extract the e-mail addresses from the func_get_args() arguments

Method Details

__construct() public method

Instantiate the object and load the mailer framework
public __construct ( )

__get() public method

Return an object property
public __get ( string $strKey ) : mixed
$strKey string The property name
return mixed The property value

__set() public method

Set an object property
public __set ( string $strKey, mixed $varValue )
$strKey string The property name
$varValue mixed The property value

addHeader() public method

Add a custom text header
public addHeader ( string $strKey, string $strValue )
$strKey string The header name
$strValue string The header value

attachFile() public method

Attach a file
public attachFile ( string $strFile, string $strMime = 'application/octet-stream' )
$strFile string The file path
$strMime string The MIME type (defaults to "application/octet-stream")

attachFileFromString() public method

Attach a file from a string
public attachFileFromString ( string $strContent, string $strFilename, string $strMime = 'application/octet-stream' )
$strContent string The file content
$strFilename string The file name
$strMime string The MIME type (defaults to "application/octet-stream")

compileRecipients() protected method

Extract the e-mail addresses from the func_get_args() arguments
protected compileRecipients ( array $arrRecipients ) : array
$arrRecipients array The recipients array
return array An array of e-mail addresses

hasFailures() public method

Return true if there are failures
public hasFailures ( ) : boolean
return boolean True if there are failures

replyTo() public method

Friendly name portions (e.g. Admin ) are allowed. The method takes an unlimited number of recipient addresses.
public replyTo ( )

sendBcc() public method

Friendly name portions (e.g. Admin ) are allowed. The method takes an unlimited number of recipient addresses.
public sendBcc ( )

sendCc() public method

Friendly name portions (e.g. Admin ) are allowed. The method takes an unlimited number of recipient addresses.
public sendCc ( )

sendTo() public method

Friendly name portions (e.g. Admin ) are allowed. The method takes an unlimited number of recipient addresses.
public sendTo ( ) : boolean
return boolean True if the e-mail was sent successfully

Property Details

$arrFailures protected_oe property

Invalid addresses
protected array $arrFailures
return array

$blnEmbedImages protected_oe property

Embed images
protected bool $blnEmbedImages
return boolean

$intPriority protected_oe property

E-mail priority
protected int $intPriority
return integer

$objMessage protected_oe property

Message object
protected Swift_Message $objMessage
return Swift_Message

$strCharset protected_oe property

Character set
protected string $strCharset
return string

$strHtml protected_oe property

HTML part of the e-mail
protected string $strHtml
return string

$strImageDir protected_oe property

Image directory
protected string $strImageDir
return string

$strLogFile protected_oe property

Log file name
protected string $strLogFile
return string

$strSender protected_oe property

Sender e-mail address
protected string $strSender
return string

$strSenderName protected_oe property

Sender name
protected string $strSenderName
return string

$strSubject protected_oe property

E-mail subject
protected string $strSubject
return string

$strText protected_oe property

Text part of the e-mail
protected string $strText
return string