AbstractSmtp
in package
implements
SmtpInterface, TransportInterface
Abstract SMTP transport class
Tags
Table of Contents
Interfaces
- SmtpInterface
- SMTP interface
- TransportInterface
- Mail transport interface
Properties
- $buffer : BufferInterface|null
- Input-Output buffer for sending/receiving SMTP commands and responses
- $domain : string
- The domain name to use in HELO command
- $sourceIp : string|null
- Source IP
- $started : bool
- Connection status
Methods
- __construct() : mixed
- Creates a new EsmtpTransport using the given I/O buffer.
- __destruct() : mixed
- Destructor
- executeCommand() : string
- Run a command against the buffer, expecting the given response codes.
- getBuffer() : BufferInterface
- Get the IoBuffer where read/writes are occurring.
- getLocalDomain() : string
- Get the name of the domain Swift will identify as
- getSourceIp() : string|null
- Returns the IP used to connect to the destination
- isStarted() : bool
- Test if an SMTP connection has been established
- reset() : void
- Reset the current mail transaction.
- send() : int
- Send the given Message.
- setLocalDomain() : AbstractSmtp
- Set the name of the local domain which Swift will identify itself as.
- setSourceIp() : AbstractSmtp
- Sets the source IP
- start() : void
- Start the SMTP connection
- stop() : void
- Stop the SMTP connection.
- assertResponseCode() : void
- Throws an Exception if a response code is incorrect
- doDataCommand() : void
- Send the DATA command
- doHeloCommand() : void
- Send the HELO welcome
- doMailFromCommand() : void
- Send the MAIL FROM command
- doRcptToCommand() : void
- Send the RCPT TO command
- getBufferParams() : array<string|int, mixed>
- Return an array of params for the Buffer
- getFullResponse() : string
- Get an entire multi-line response using its sequence number
- getReversePath() : null|string
- Determine the best-use reverse path for this message
- readGreeting() : void
- Read the opening SMTP greeting
- streamMessage() : void
- Stream the contents of the message over the buffer
- throwException() : void
- Throw a TransportException, first sending it to any listeners
- doMailTransaction() : int
- Send an email to the given recipients from the given reverse path
- isFqdn() : bool
- Determine is the $hostname is a fully-qualified name
- lookupHostname() : void
- Try to determine the hostname of the server this is run on
- sendBcc() : int
- Send a message to all Bcc: recipients
- sendTo() : int
- Send a message to the given To: recipients
Properties
$buffer
Input-Output buffer for sending/receiving SMTP commands and responses
protected
BufferInterface|null
$buffer
= null
$domain
The domain name to use in HELO command
protected
string
$domain
= '[127.0.0.1]'
$sourceIp
Source IP
protected
string|null
$sourceIp
= null
$started
Connection status
protected
bool
$started
= false
Methods
__construct()
Creates a new EsmtpTransport using the given I/O buffer.
public
__construct(BufferInterface $buffer) : mixed
Parameters
- $buffer : BufferInterface
__destruct()
Destructor
public
__destruct() : mixed
executeCommand()
Run a command against the buffer, expecting the given response codes.
public
executeCommand(string $command[, array<string|int, mixed> $codes = [] ]) : string
If no response codes are given, the response will not be validated. If codes are given, an exception will be thrown on an invalid response.
Parameters
- $command : string
- $codes : array<string|int, mixed> = []
Return values
stringgetBuffer()
Get the IoBuffer where read/writes are occurring.
public
getBuffer() : BufferInterface
Return values
BufferInterfacegetLocalDomain()
Get the name of the domain Swift will identify as
public
getLocalDomain() : string
Return values
stringgetSourceIp()
Returns the IP used to connect to the destination
public
getSourceIp() : string|null
Return values
string|nullisStarted()
Test if an SMTP connection has been established
public
isStarted() : bool
Return values
boolreset()
Reset the current mail transaction.
public
reset() : void
send()
Send the given Message.
public
send(Message $message) : int
Recipient/sender data will be retrieved from the Message API. The return value is the number of recipients who were accepted for delivery.
Parameters
- $message : Message
Tags
Return values
intsetLocalDomain()
Set the name of the local domain which Swift will identify itself as.
public
setLocalDomain(string $domain) : AbstractSmtp
This should be a fully-qualified domain name and should be truly the domain you're using.
If your server doesn't have a domain name, use the IP in square brackets (i.e. [127.0.0.1]).
Parameters
- $domain : string
Return values
AbstractSmtpsetSourceIp()
Sets the source IP
public
setSourceIp(string $source) : AbstractSmtp
Parameters
- $source : string
Return values
AbstractSmtpstart()
Start the SMTP connection
public
start() : void
stop()
Stop the SMTP connection.
public
stop() : void
assertResponseCode()
Throws an Exception if a response code is incorrect
protected
assertResponseCode(string $response, array<string|int, mixed> $wanted) : void
Parameters
- $response : string
- $wanted : array<string|int, mixed>
doDataCommand()
Send the DATA command
protected
doDataCommand() : void
doHeloCommand()
Send the HELO welcome
protected
doHeloCommand() : void
doMailFromCommand()
Send the MAIL FROM command
protected
doMailFromCommand(string $address) : void
Parameters
- $address : string
doRcptToCommand()
Send the RCPT TO command
protected
doRcptToCommand(string $address) : void
Parameters
- $address : string
getBufferParams()
Return an array of params for the Buffer
protected
abstract getBufferParams() : array<string|int, mixed>
Return values
array<string|int, mixed>getFullResponse()
Get an entire multi-line response using its sequence number
protected
getFullResponse(string $seq) : string
Parameters
- $seq : string
Tags
Return values
stringgetReversePath()
Determine the best-use reverse path for this message
protected
getReversePath(Message $message) : null|string
Parameters
- $message : Message
Return values
null|stringreadGreeting()
Read the opening SMTP greeting
protected
readGreeting() : void
streamMessage()
Stream the contents of the message over the buffer
protected
streamMessage(Message $message) : void
Parameters
- $message : Message
throwException()
Throw a TransportException, first sending it to any listeners
protected
throwException(Exception $e) : void
Parameters
- $e : Exception
Tags
doMailTransaction()
Send an email to the given recipients from the given reverse path
private
doMailTransaction(Message $message, string $reversePath, array<string|int, mixed> $recipients) : int
Parameters
- $message : Message
- $reversePath : string
- $recipients : array<string|int, mixed>
Return values
intisFqdn()
Determine is the $hostname is a fully-qualified name
private
isFqdn(string $hostname) : bool
Parameters
- $hostname : string
Return values
boollookupHostname()
Try to determine the hostname of the server this is run on
private
lookupHostname() : void
sendBcc()
Send a message to all Bcc: recipients
private
sendBcc(Message $message, string $reversePath, array<string|int, mixed> $bcc) : int
Parameters
- $message : Message
- $reversePath : string
- $bcc : array<string|int, mixed>
Return values
intsendTo()
Send a message to the given To: recipients
private
sendTo(Message $message, string $reversePath, array<string|int, mixed> $to) : int
Parameters
- $message : Message
- $reversePath : string
- $to : array<string|int, mixed>