SMTPs
class SMTPs (View source)
Class to construct and send SMTP compliant email, even to a secure SMTP server, regardless of platform.
Properties
| string | $log | ||
| string | $lastretval | ||
| resource | $socket | ||
| int | $errno | ||
| string | $errstr |
Methods
Set Message-ID
Set options
Set delivery receipt
get delivery receipt
Set socket timeout. May be increase when email sent after a long time and with a large file for the wake up of SMTP server.
Get socket timeout
Set trackid
Set moreInHeader
get trackid
get moreInHeader
Set errors to
Get errors to
Set debug
build RECIPIENT List, all addresses who will receive this message
Now send the message
setConfig() is used to populate select class properties from either a user defined INI file or the systems 'php.ini' file
Determines the method inwhich the messages are to be sent.
Return the method inwhich the message is to be sent.
Path to the sendmail executable
Defines the Host Name or IP of the Mail Server to use.
Retrieves the Host Name or IP of the Mail Server to use This is used only with 'socket' based mail transmission
Defines the Port Number of the Mail Server to use The default is 25 This is used only with 'socket' based mail transmission
Retrieves the Port Number of the Mail Server to use This is used only with 'socket' based mail transmission
User Name for authentication on Mail Server
Retrieves the User Name for authentication on Mail Server
User Password for authentication on Mail Server
Retrieves the User Password for authentication on Mail Server
User token for OAUTH2
Retrieves the User token for OAUTH2
Character set used for current message Character set is defaulted to 'iso-8859-1';
Retrieves the Character set used for current message
Content-Transfer-Encoding, Defaulted to '7bit' This can be changed for 2byte characters sets Known Encode Types
- 7bit Simple 7-bit ASCII
- 8bit 8-bit coding with line termination characters
- base64 3 octets encoded into 4 sextets with offset
- binary Arbitrary binary stream
- mac-binhex40 Macintosh binary to hex encoding
- quoted-printable Mostly 7-bit, with 8-bit characters encoded as "=HH"
- uuencode UUENCODE encoding
Retrieves the Content-Transfer-Encoding
Content-Transfer-Encoding, Defaulted to '0' [ZERO] This can be changed for 2byte characters sets Known Encode Types
- [0] 7bit Simple 7-bit ASCII
- [1] 8bit 8-bit coding with line termination characters
- [2] base64 3 octets encoded into 4 sextets with offset
- [3] binary Arbitrary binary stream
- [4] mac-binhex40 Macintosh binary to hex encoding
- [5] quoted-printable Mostly 7-bit, with 8-bit characters encoded as "=HH"
- [6] uuencode UUENCODE encoding
Retrieves the Content-Transfer-Encoding
FROM Address from which mail will be sent
Retrieves the Address from which mail will be sent
Reply-To Address from which mail will be the reply-to
Retrieves the Address from which mail will be the reply-to
Set References in the list of Msg-Id
Retrieves the InReplyTo from which mail we reply to
Set References in the list of Msg-Id
Retrieves the References from which mail will be the reply-to
Returns an array of bare addresses for use with 'RCPT TO:' This is a "build as you go" method. Each time this method is called the underlying array is destroyed and reconstructed.
Returns an array of addresses for a specific type; TO, CC or BCC
TO Address[es] inwhich to send mail to
Retrieves the TO Address[es] inwhich to send mail to
CC Address[es] inwhich to send mail to
Retrieves the CC Address[es] inwhich to send mail to
BCC Address[es] inwhich to send mail to
Retrieves the BCC Address[es] inwhich to send mail to
Message Subject
Retrieves the Message Subject
Constructs and returns message header
Message Content
Retrieves the Message Content
File attachments are added to the content array as sub-arrays, allowing for multiple attachments for each outbound email
Image attachments are added to the content array as sub-arrays, allowing for multiple images for each outbound email
Message Content Sensitivity Message Sensitivity values:
- [0] None - default
- [1] Personal
- [2] Private
- [3] Company Confidential
Returns Message Content Sensitivity string Message Sensitivity values:
- [0] None - default
- [1] Personal
- [2] Private
- [3] Company Confidential
Message Content Priority Message Priority values:
- [0] 'Bulk'
- [1] 'Highest'
- [2] 'High'
- [3] 'Normal' - default
- [4] 'Low'
- [5] 'Lowest'
Message Content Priority Message Priority values:
- [0] 'Bulk'
- [1] 'Highest'
- [2] 'High'
- [3] 'Normal' - default
- [4] 'Low'
- [5] 'Lowest'
Set flag which determines whether to calculate message MD5 checksum.
Gets flag which determines whether to calculate message MD5 checksum.
Message X-Header Content This is a simple "insert". Whatever is given will be placed "as is" into the Xheader array.
Retrieves the Message X-Header Content
This function has been modified as provided by SirSir to allow multiline responses when using SMTP Extensions
Send str
Returns applicative errors codes and messages for Class (not the SMTP error code)
Details
void
setMessageID(string $_msgId = '')
Set Message-ID
void
setOptions(array<string, array<string, mixed>> $_options = array())
Set options
void
setDeliveryReceipt(int $_val = 0)
Set delivery receipt
int
getDeliveryReceipt()
get delivery receipt
void
setSMTPTimeout(int $timeout)
Set socket timeout. May be increase when email sent after a long time and with a large file for the wake up of SMTP server.
int
getSMTPTimeout()
Get socket timeout
void
setTrackId(string $_val = '')
Set trackid
void
setMoreInHeader(string $_val = '')
Set moreInHeader
string
getTrackId()
get trackid
string
getMoreInHeader()
get moreInHeader
void
setErrorsTo(string $_strErrorsTo)
Set errors to
string|array<string, string>
getErrorsTo(true|string $_part = true)
Get errors to
void
setDebug(bool $_vDebug = false)
Set debug
void
buildRCPTlist()
build RECIPIENT List, all addresses who will receive this message
bool|null
sendMsg()
Now send the message
bool
setConfig(mixed $_strConfigPath = null)
setConfig() is used to populate select class properties from either a user defined INI file or the systems 'php.ini' file
If a user defined INI is to be used, the files complete path is passed as the method single parameter. The INI can define any class and/or user properties. Only properties defined within this file will be setter and/or orverwritten
If the systems 'php.ini' file is to be used, the method is called without parameters. In this case, only HOST, PORT and FROM properties will be set as they are the only properties that are defined within the 'php.ini'.
If secure SMTP is to be used, the user ID and Password can be defined with the user INI file, but the properties are not defined with the systems 'php.ini'file, they must be defined via their setter methods
This method can be called twice, if desired. Once without a parameter to load the properties as defined within the systems 'php.ini' file, and a second time, with a path to a user INI file for other properties to be defined.
void
setTransportType(int $_type = 0)
Determines the method inwhich the messages are to be sent.
- 'sockets' [0] - connect via network to SMTP server
- 'pipe [1] - use UNIX path to EXE
- 'phpmail [2] - use the PHP built-in mail function
int
getTransportType()
Return the method inwhich the message is to be sent.
- 'sockets' [0] - connect via network to SMTP server
- 'pipe [1] - use UNIX path to EXE
- 'phpmail [2] - use the PHP built-in mail function
bool
setMailPath(string $_path)
Path to the sendmail executable
void
setHost(string $_strHost)
Defines the Host Name or IP of the Mail Server to use.
This is defaulted to 'localhost' This is used only with 'socket' based mail transmission
string
getHost()
Retrieves the Host Name or IP of the Mail Server to use This is used only with 'socket' based mail transmission
void
setPort(int|string $_intPort)
Defines the Port Number of the Mail Server to use The default is 25 This is used only with 'socket' based mail transmission
int
getPort()
Retrieves the Port Number of the Mail Server to use This is used only with 'socket' based mail transmission
void
setID(string $_strID)
User Name for authentication on Mail Server
string
getID()
Retrieves the User Name for authentication on Mail Server
void
setPW(string $_strPW)
User Password for authentication on Mail Server
string
getPW()
Retrieves the User Password for authentication on Mail Server
void
setToken(string $_strToken)
User token for OAUTH2
string
getToken()
Retrieves the User token for OAUTH2
void
setCharSet(string $_strCharSet)
Character set used for current message Character set is defaulted to 'iso-8859-1';
string
getCharSet()
Retrieves the Character set used for current message
void
setTransEncode(string $_strTransEncode)
Content-Transfer-Encoding, Defaulted to '7bit' This can be changed for 2byte characters sets Known Encode Types
- 7bit Simple 7-bit ASCII
- 8bit 8-bit coding with line termination characters
- base64 3 octets encoded into 4 sextets with offset
- binary Arbitrary binary stream
- mac-binhex40 Macintosh binary to hex encoding
- quoted-printable Mostly 7-bit, with 8-bit characters encoded as "=HH"
- uuencode UUENCODE encoding
string
getTransEncode()
Retrieves the Content-Transfer-Encoding
void
setTransEncodeType(string $_strTransEncodeType)
Content-Transfer-Encoding, Defaulted to '0' [ZERO] This can be changed for 2byte characters sets Known Encode Types
- [0] 7bit Simple 7-bit ASCII
- [1] 8bit 8-bit coding with line termination characters
- [2] base64 3 octets encoded into 4 sextets with offset
- [3] binary Arbitrary binary stream
- [4] mac-binhex40 Macintosh binary to hex encoding
- [5] quoted-printable Mostly 7-bit, with 8-bit characters encoded as "=HH"
- [6] uuencode UUENCODE encoding
string
getTransEncodeType()
Retrieves the Content-Transfer-Encoding
void
setFrom(string $_strFrom)
FROM Address from which mail will be sent
null|string|array{org: string, real?: string, addr: string, user: string, host: string}
getFrom(true|string $_part = true)
Retrieves the Address from which mail will be sent
void
setReplyTo(string $_strReplyTo)
Reply-To Address from which mail will be the reply-to
null|array<string, string>|string
getReplyTo(true|string $_part = true)
Retrieves the Address from which mail will be the reply-to
void
setInReplyTo(string $_strInReplyTo)
Set References in the list of Msg-Id
string
getInReplyTo()
Retrieves the InReplyTo from which mail we reply to
void
setReferences(string[] $_strReferences)
Set References in the list of Msg-Id
?string[]
getReferences()
Retrieves the References from which mail will be the reply-to
string[]
get_RCPT_list()
Returns an array of bare addresses for use with 'RCPT TO:' This is a "build as you go" method. Each time this method is called the underlying array is destroyed and reconstructed.
string|false
get_email_list(string $_which = null)
Returns an array of addresses for a specific type; TO, CC or BCC
void
setTO(string $_addrTo)
TO Address[es] inwhich to send mail to
string
getTo()
Retrieves the TO Address[es] inwhich to send mail to
void
setCC(string $_strCC)
CC Address[es] inwhich to send mail to
string
getCC()
Retrieves the CC Address[es] inwhich to send mail to
void
setBCC(string $_strBCC)
BCC Address[es] inwhich to send mail to
string
getBCC()
Retrieves the BCC Address[es] inwhich to send mail to
void
setSubject(string $_strSubject = '')
Message Subject
string
getSubject()
Retrieves the Message Subject
string
getHeader()
Constructs and returns message header
void
setBodyContent(string $strContent, string $strType = 'plain')
Message Content
string
getBodyContent()
Retrieves the Message Content
void
setAttachment(string $strContent, string $strFileName = 'unknown', string $strMimeType = 'unknown', string $strCid = '')
File attachments are added to the content array as sub-arrays, allowing for multiple attachments for each outbound email
void
setImageInline(string $strContent, string $strImageName = 'unknown', string $strMimeType = 'unknown', string $strImageCid = 'unknown')
Image attachments are added to the content array as sub-arrays, allowing for multiple images for each outbound email
void
setSensitivity(int $_value = 0)
Message Content Sensitivity Message Sensitivity values:
- [0] None - default
- [1] Personal
- [2] Private
- [3] Company Confidential
string|bool
getSensitivity()
Returns Message Content Sensitivity string Message Sensitivity values:
- [0] None - default
- [1] Personal
- [2] Private
- [3] Company Confidential
void
setPriority(int $_value = 3)
Message Content Priority Message Priority values:
- [0] 'Bulk'
- [1] 'Highest'
- [2] 'High'
- [3] 'Normal' - default
- [4] 'Low'
- [5] 'Lowest'
string
getPriority()
Message Content Priority Message Priority values:
- [0] 'Bulk'
- [1] 'Highest'
- [2] 'High'
- [3] 'Normal' - default
- [4] 'Low'
- [5] 'Lowest'
void
setMD5flag(bool $_flag = false)
Set flag which determines whether to calculate message MD5 checksum.
bool
getMD5flag()
Gets flag which determines whether to calculate message MD5 checksum.
void
setXheader(string $strXdata)
Message X-Header Content This is a simple "insert". Whatever is given will be placed "as is" into the Xheader array.
string[]
getXheader()
Retrieves the Message X-Header Content
bool
server_parse(resource $socket, string $response)
This function has been modified as provided by SirSir to allow multiline responses when using SMTP Extensions
bool|null
socket_send_str(string $_strSend, string $_returnCode = null, string $CRLF = "\r\n")
Send str
string
getErrors()
Returns applicative errors codes and messages for Class (not the SMTP error code)