Email
in package
Send email class using SMTP Authentication
Tags
Table of Contents
- CRLF = " "
- OK = 250
- SSL = 'ssl'
- TLS = 'tcp'
- $attachments : array<string|int, mixed>
- $bcc : array<string|int, mixed>
- $cc : array<string|int, mixed>
- $charset : string
- $connectionTimeout : int
- $from : array<string|int, mixed>
- $headers : array<string|int, mixed>
- $hostname : string
- $htmlMessage : string|null
- $isHTML : bool
- $isTLS : bool
- $logs : array<string|int, mixed>
- $password : string
- $port : int
- $protocol : string|null
- $replyTo : array<string|int, mixed>
- $responseTimeout : int
- $server : string
- $socket : resource
- $subject : string
- $textMessage : string|null
- $to : array<string|int, mixed>
- $username : string
- __construct() : mixed
- Class constructor -- Set server name, port and timeout values
- addAttachment() : Email
- Add file attachment
- addBcc() : Email
- Add blind carbon copy email address
- addCc() : Email
- Add carbon copy email address
- addReplyTo() : Email
- Add email reply to address
- addTo() : Email
- Add to recipient email address
- getLogs() : array<string|int, mixed>
- Get log array -- contains commands and responses from SMTP server
- send() : bool
- Send email to recipient via mail server
- setCharset() : Email
- Get message character set
- setFrom() : Email
- Set from email address and/or name
- setHtmlMessage() : Email
- Set html message body
- setLogin() : Email
- Set SMTP Login authentication
- setProtocol() : Email
- Set SMTP Server protocol -- default value is null (no secure protocol)
- setSubject() : Email
- Set email subject string
- setTextMessage() : Email
- Set plain text message body
- formatAddress() : string
- Format email address (with name)
- formatAddressList() : string
- Format email address to list
- getResponse() : string
- Get Mail Server response
- getServer() : string
- Get server url -- if set SMTP protocol then prepend it to server
- sendCommand() : string
- Send command to mail server
Constants
CRLF
public
mixed
CRLF
= "
"
OK
public
mixed
OK
= 250
SSL
public
mixed
SSL
= 'ssl'
TLS
public
mixed
TLS
= 'tcp'
Properties
$attachments
protected
array<string|int, mixed>
$attachments
= array()
$bcc
protected
array<string|int, mixed>
$bcc
= array()
$cc
protected
array<string|int, mixed>
$cc
= array()
$charset
protected
string
$charset
= 'utf-8'
$connectionTimeout
protected
int
$connectionTimeout
$from
protected
array<string|int, mixed>
$from
= array()
$headers
protected
array<string|int, mixed>
$headers
= array()
$hostname
protected
string
$hostname
$htmlMessage
protected
string|null
$htmlMessage
= null
$isHTML
protected
bool
$isHTML
= false
$isTLS
protected
bool
$isTLS
= false
$logs
protected
array<string|int, mixed>
$logs
= array()
$password
protected
string
$password
$port
protected
int
$port
$protocol
protected
string|null
$protocol
= null
$replyTo
protected
array<string|int, mixed>
$replyTo
= array()
$responseTimeout
protected
int
$responseTimeout
$server
protected
string
$server
$socket
protected
resource
$socket
$subject
protected
string
$subject
$textMessage
protected
string|null
$textMessage
= null
$to
protected
array<string|int, mixed>
$to
= array()
$username
protected
string
$username
Methods
__construct()
Class constructor -- Set server name, port and timeout values
public
__construct(string $server[, int $port = 25 ][, int $connectionTimeout = 30 ][, int $responseTimeout = 8 ][, string|null $hostname = null ]) : mixed
Parameters
- $server : string
- $port : int = 25
- $connectionTimeout : int = 30
- $responseTimeout : int = 8
- $hostname : string|null = null
Return values
mixed —addAttachment()
Add file attachment
public
addAttachment(string $attachment) : Email
Parameters
- $attachment : string
Return values
Email —addBcc()
Add blind carbon copy email address
public
addBcc(string $address[, string|null $name = null ]) : Email
Parameters
- $address : string
- $name : string|null = null
Return values
Email —addCc()
Add carbon copy email address
public
addCc(string $address[, string|null $name = null ]) : Email
Parameters
- $address : string
- $name : string|null = null
Return values
Email —addReplyTo()
Add email reply to address
public
addReplyTo(string $address[, string|null $name = null ]) : Email
Parameters
- $address : string
- $name : string|null = null
Return values
Email —addTo()
Add to recipient email address
public
addTo(string $address[, string|null $name = null ]) : Email
Parameters
- $address : string
- $name : string|null = null
Return values
Email —getLogs()
Get log array -- contains commands and responses from SMTP server
public
getLogs() : array<string|int, mixed>
Return values
array<string|int, mixed> —send()
Send email to recipient via mail server
public
send() : bool
Return values
bool —setCharset()
Get message character set
public
setCharset(string $charset) : Email
Parameters
- $charset : string
Return values
Email —setFrom()
Set from email address and/or name
public
setFrom(string $address[, string|null $name = null ]) : Email
Parameters
- $address : string
- $name : string|null = null
Return values
Email —setHtmlMessage()
Set html message body
public
setHtmlMessage(string $message) : Email
Parameters
- $message : string
Return values
Email —setLogin()
Set SMTP Login authentication
public
setLogin(string $username, string $password) : Email
Parameters
- $username : string
- $password : string
Return values
Email —setProtocol()
Set SMTP Server protocol -- default value is null (no secure protocol)
public
setProtocol([string $protocol = null ]) : Email
Parameters
- $protocol : string = null
Return values
Email —setSubject()
Set email subject string
public
setSubject(string $subject) : Email
Parameters
- $subject : string
Return values
Email —setTextMessage()
Set plain text message body
public
setTextMessage(string $message) : Email
Parameters
- $message : string
Return values
Email —formatAddress()
Format email address (with name)
protected
formatAddress(array<string|int, mixed> $address) : string
Parameters
- $address : array<string|int, mixed>
Return values
string —formatAddressList()
Format email address to list
protected
formatAddressList(array<string|int, mixed> $addresses) : string
Parameters
- $addresses : array<string|int, mixed>
Return values
string —getResponse()
Get Mail Server response
protected
getResponse() : string
Return values
string —getServer()
Get server url -- if set SMTP protocol then prepend it to server
protected
getServer() : string
Return values
string —sendCommand()
Send command to mail server
protected
sendCommand(string $command) : string
Parameters
- $command : string