dolibarr
x.y.z
|
Class to construct and send SMTP compliant email, even to a secure SMTP server, regardless of platform. More...
Public Member Functions | |
setOptions ($_options=array()) | |
Set delivery receipt. More... | |
setDeliveryReceipt ($_val=0) | |
Set delivery receipt. More... | |
getDeliveryReceipt () | |
get delivery receipt More... | |
setTrackId ($_val='') | |
Set trackid. More... | |
setMoreInHeader ($_val='') | |
Set moreInHeader. More... | |
getTrackId () | |
get trackid More... | |
getMoreInHeader () | |
get moreInHeader More... | |
setErrorsTo ($_strErrorsTo) | |
Set errors to. More... | |
getErrorsTo ($_part=true) | |
Get errors to. More... | |
setDebug ($_vDebug=false) | |
Set debug. More... | |
buildRCPTlist () | |
build RECIPIENT List, all addresses who will recieve this message More... | |
sendMsg () | |
Now send the message. More... | |
setConfig ($_strConfigPath=null) | |
setConfig() is used to populate select class properties from either a user defined INI file or the systems 'php.ini' file More... | |
setTransportType ($_type=0) | |
Determines the method inwhich the messages are to be sent. More... | |
getTransportType () | |
Return the method inwhich the message is to be sent. More... | |
setMailPath ($_path) | |
Path to the sendmail execuable. More... | |
setHost ($_strHost) | |
Defines the Host Name or IP of the Mail Server to use. More... | |
getHost () | |
Retrieves the Host Name or IP of the Mail Server to use This is used only with 'socket' based mail transmission. More... | |
setPort ($_intPort) | |
Defines the Port Number of the Mail Server to use This is defaulted to '25' This is used only with 'socket' based mail transmission. More... | |
getPort () | |
Retrieves the Port Number of the Mail Server to use This is used only with 'socket' based mail transmission. More... | |
setID ($_strID) | |
User Name for authentication on Mail Server. More... | |
getID () | |
Retrieves the User Name for authentication on Mail Server. More... | |
setPW ($_strPW) | |
User Password for authentication on Mail Server. More... | |
getPW () | |
Retrieves the User Password for authentication on Mail Server. More... | |
setToken ($_strToken) | |
User token for OAUTH2. More... | |
getToken () | |
Retrieves the User token for OAUTH2. More... | |
setCharSet ($_strCharSet) | |
Character set used for current message Character set is defaulted to 'iso-8859-1';. More... | |
getCharSet () | |
Retrieves the Character set used for current message. More... | |
setTransEncode ($_strTransEncode) | |
Content-Transfer-Encoding, Defaulted to '7bit' This can be changed for 2byte characers sets Known Encode Types. More... | |
getTransEncode () | |
Retrieves the Content-Transfer-Encoding. More... | |
setTransEncodeType ($_strTransEncodeType) | |
Content-Transfer-Encoding, Defaulted to '0' [ZERO] This can be changed for 2byte characers sets Known Encode Types. More... | |
getTransEncodeType () | |
Retrieves the Content-Transfer-Encoding. More... | |
setFrom ($_strFrom) | |
FROM Address from which mail will be sent. More... | |
getFrom ($_part=true) | |
Retrieves the Address from which mail will be sent. More... | |
setReplyTo ($_strReplyTo) | |
Reply-To Address from which mail will be the reply-to. More... | |
getReplyTo ($_part=true) | |
Retrieves the Address from which mail will be the reply-to. More... | |
get_RCPT_list () | |
Returns an array of bares addresses for use with 'RCPT TO:' This is a "build as you go" method. More... | |
get_email_list ($_which=null) | |
Returns an array of addresses for a specific type; TO, CC or BCC. More... | |
setTO ($_addrTo) | |
TO Address[es] inwhich to send mail to. More... | |
getTo () | |
Retrieves the TO Address[es] inwhich to send mail to. More... | |
setCC ($_strCC) | |
CC Address[es] inwhich to send mail to. More... | |
getCC () | |
Retrieves the CC Address[es] inwhich to send mail to. More... | |
setBCC ($_strBCC) | |
BCC Address[es] inwhich to send mail to. More... | |
getBCC () | |
Retrieves the BCC Address[es] inwhich to send mail to. More... | |
setSubject ($_strSubject='') | |
Message Subject. More... | |
getSubject () | |
Retrieves the Message Subject. More... | |
getHeader () | |
Constructes and returns message header. More... | |
setBodyContent ($strContent, $strType='plain') | |
Message Content. More... | |
getBodyContent () | |
Retrieves the Message Content. More... | |
setAttachment ($strContent, $strFileName='unknown', $strMimeType='unknown', $strCid='') | |
File attachments are added to the content array as sub-arrays, allowing for multiple attachments for each outbound email. More... | |
setImageInline ($strContent, $strImageName='unknown', $strMimeType='unknown', $strImageCid='unknown') | |
Image attachments are added to the content array as sub-arrays, allowing for multiple images for each outbound email. More... | |
setSensitivity ($_value=0) | |
Message Content Sensitivity Message Sensitivity values: More... | |
getSensitivity () | |
Returns Message Content Sensitivity string Message Sensitivity values: More... | |
setPriority ($_value=3) | |
Message Content Priority Message Priority values: More... | |
getPriority () | |
Message Content Priority Message Priority values: More... | |
setMD5flag ($_flag=false) | |
Set flag which determines whether to calculate message MD5 checksum. More... | |
getMD5flag () | |
Gets flag which determines whether to calculate message MD5 checksum. More... | |
setXheader ($strXdata) | |
Message X-Header Content This is a simple "insert". More... | |
getXheader () | |
Retrieves the Message X-Header Content. More... | |
server_parse ($socket, $response) | |
This function has been modified as provided by SirSir to allow multiline responses when using SMTP Extensions. More... | |
socket_send_str ($_strSend, $_returnCode=null, $CRLF="\r\n") | |
Send str. More... | |
getErrors () | |
Returns errors codes and messages for Class. More... | |
Private Member Functions | |
_server_connect () | |
Attempt a connection to mail server. More... | |
_server_authenticate () | |
Attempt mail server authentication for a secure connection. More... | |
_buildAddrList ($_type, $_addrList) | |
Inserts given addresses into structured format. More... | |
_strip_email ($_strAddr) | |
Returns an array of the various parts of an email address This assumes a well formed address: More... | |
_setBoundary () | |
Generates Random string for MIME message Boundary. More... | |
_getBoundary ($type='mixed') | |
Retrieves the MIME message Boundary. More... | |
_setErr ($_errNum, $_errMsg) | |
Defines errors codes and messages for Class. More... | |
Private Attributes | |
$_smtpsHost = 'localhost' | |
Host Name or IP of SMTP Server to use. | |
$_smtpsPort = '25' | |
SMTP Server Port definition. More... | |
$_smtpsID = null | |
Secure SMTP Server access ID This can be defined via a INI file or via a setter method. | |
$_smtpsPW = null | |
Secure SMTP Server access Password This can be defined via a INI file or via a setter method. | |
$_smtpsToken = null | |
Token in case we use OAUTH2. | |
$_msgFrom = null | |
Who sent the Message This can be defined via a INI file or via a setter method. | |
$_msgReplyTo = null | |
Where are replies and errors to be sent to This can be defined via a INI file or via a setter method. | |
$_msgRecipients = null | |
Who will the Message be sent to; TO, CC, BCC Multi-diminsional array containg addresses the message will be sent TO, CC or BCC. | |
$_msgSubject = null | |
Message Subject. | |
$_msgContent = null | |
Message Content. | |
$_msgXheader = null | |
Custom X-Headers. | |
$_smtpsCharSet = 'iso-8859-1' | |
Character set Defaulted to 'iso-8859-1'. | |
$_msgSensitivity = 0 | |
Message Sensitivity Defaults to ZERO - None. | |
$_arySensitivity | |
Message Sensitivity. | |
$_msgPriority = 3 | |
Message Sensitivity Defaults to 3 - Normal. | |
$_aryPriority | |
Message Priority. | |
$_smtpsTransEncodeType = 0 | |
Content-Transfer-Encoding Defaulted to 0 - 7bit. | |
$_smtpsTransEncodeTypes | |
Content-Transfer-Encoding. | |
$_smtpsTransEncode = '7bit' | |
Content-Transfer-Encoding Defaulted to '7bit'. | |
$_smtpsBoundary = null | |
Boundary String for MIME seperation. | |
$_smtpsRelatedBoundary = null | |
Related Boundary. | |
$_smtpsAlternativeBoundary = null | |
Alternative Boundary. | |
$_transportType = 0 | |
Determines the method inwhich the message are to be sent. More... | |
$_mailPath = '/usr/lib/sendmail' | |
If '$_transportType' is set to '1', then this variable is used to define the UNIX file system path to the sendmail execuable. | |
$_smtpTimeout = 10 | |
Sets the SMTP server timeout in seconds. | |
$_smtpMD5 = false | |
Determines whether to calculate message MD5 checksum. | |
$_smtpsErrors = null | |
Class error codes and messages. | |
$_log_level = 0 | |
Defines log level 0 - no logging 1 - connectivity logging 2 - message generation logging 3 - detail logging. | |
$_debug = false | |
Place Class in" debug" mode. | |
$_options = array() | |
An array of options for stream_context_create() | |
Class to construct and send SMTP compliant email, even to a secure SMTP server, regardless of platform.
Definition at line 46 of file smtps.class.php.
|
private |
Inserts given addresses into structured format.
This method takes a list of given addresses, via an array or a COMMA delimted string, and inserts them into a highly structured array. This array is designed to remove duplicate addresses and to sort them by Domain.
string | $_type | TO, CC, or BCC lists to add addrresses into |
mixed | $_addrList | Array or COMMA delimited string of addresses |
Definition at line 1121 of file smtps.class.php.
References $_msgRecipients.
|
private |
Retrieves the MIME message Boundary.
string | $type | Type of boundary |
Definition at line 1856 of file smtps.class.php.
|
private |
Attempt mail server authentication for a secure connection.
Definition at line 453 of file smtps.class.php.
|
private |
Attempt a connection to mail server.
Definition at line 375 of file smtps.class.php.
References getHost().
|
private |
Generates Random string for MIME message Boundary.
Definition at line 1843 of file smtps.class.php.
|
private |
Defines errors codes and messages for Class.
int | $_errNum | Error Code Number |
string | $_errMsg | Error Message |
Definition at line 1943 of file smtps.class.php.
Referenced by get_email_list(), and setConfig().
|
private |
Returns an array of the various parts of an email address This assumes a well formed address:
string | $_strAddr | Email address |
Definition at line 1188 of file smtps.class.php.
Referenced by setErrorsTo(), setFrom(), and setReplyTo().
SMTPs::buildRCPTlist | ( | ) |
build RECIPIENT List, all addresses who will recieve this message
Definition at line 363 of file smtps.class.php.
SMTPs::get_email_list | ( | $_which = null | ) |
Returns an array of addresses for a specific type; TO, CC or BCC.
string | $_which | Which collection of addresses to return ('to', 'cc', 'bcc') |
Definition at line 1260 of file smtps.class.php.
References _setErr().
SMTPs::get_RCPT_list | ( | ) |
Returns an array of bares addresses for use with 'RCPT TO:' This is a "build as you go" method.
Each time this method is called the underlaying array is destroyed and reconstructed.
An array of bares addresses for use with 'RCPT TO:'
Definition at line 1232 of file smtps.class.php.
SMTPs::getBCC | ( | ) |
Retrieves the BCC Address[es] inwhich to send mail to.
Definition at line 1357 of file smtps.class.php.
References get_email_list().
SMTPs::getBodyContent | ( | ) |
Retrieves the Message Content.
Definition at line 1516 of file smtps.class.php.
SMTPs::getCC | ( | ) |
Retrieves the CC Address[es] inwhich to send mail to.
Definition at line 1334 of file smtps.class.php.
References get_email_list().
SMTPs::getCharSet | ( | ) |
Retrieves the Character set used for current message.
Definition at line 972 of file smtps.class.php.
References $_smtpsCharSet.
SMTPs::getDeliveryReceipt | ( | ) |
SMTPs::getErrors | ( | ) |
Returns errors codes and messages for Class.
Definition at line 1956 of file smtps.class.php.
SMTPs::getErrorsTo | ( | $_part = true | ) |
Get errors to.
boolean | $_part | Variant |
Definition at line 334 of file smtps.class.php.
SMTPs::getFrom | ( | $_part = true | ) |
Retrieves the Address from which mail will be sent.
boolean | $_part | To "strip" 'Real name' from address |
Definition at line 1064 of file smtps.class.php.
References $_msgFrom.
SMTPs::getHeader | ( | ) |
Constructes and returns message header.
Definition at line 1390 of file smtps.class.php.
SMTPs::getHost | ( | ) |
Retrieves the Host Name or IP of the Mail Server to use This is used only with 'socket' based mail transmission.
Definition at line 858 of file smtps.class.php.
References $_smtpsHost.
Referenced by _server_connect().
SMTPs::getID | ( | ) |
Retrieves the User Name for authentication on Mail Server.
Definition at line 906 of file smtps.class.php.
References $_smtpsID.
SMTPs::getMD5flag | ( | ) |
Gets flag which determines whether to calculate message MD5 checksum.
Definition at line 1808 of file smtps.class.php.
References $_smtpMD5.
Referenced by setAttachment(), setBodyContent(), and setImageInline().
SMTPs::getMoreInHeader | ( | ) |
SMTPs::getPort | ( | ) |
Retrieves the Port Number of the Mail Server to use This is used only with 'socket' based mail transmission.
Definition at line 885 of file smtps.class.php.
References $_smtpsPort.
SMTPs::getPriority | ( | ) |
Message Content Priority Message Priority values:
Definition at line 1785 of file smtps.class.php.
References $_msgPriority.
SMTPs::getPW | ( | ) |
Retrieves the User Password for authentication on Mail Server.
Definition at line 927 of file smtps.class.php.
References $_smtpsPW.
SMTPs::getReplyTo | ( | $_part = true | ) |
Retrieves the Address from which mail will be the reply-to.
boolean | $_part | To "strip" 'Real name' from address |
Definition at line 1096 of file smtps.class.php.
References $_msgReplyTo.
SMTPs::getSensitivity | ( | ) |
Returns Message Content Sensitivity string Message Sensitivity values:
Definition at line 1747 of file smtps.class.php.
References $_msgSensitivity.
SMTPs::getSubject | ( | ) |
Retrieves the Message Subject.
Definition at line 1380 of file smtps.class.php.
References $_msgSubject.
SMTPs::getTo | ( | ) |
Retrieves the TO Address[es] inwhich to send mail to.
Definition at line 1311 of file smtps.class.php.
References get_email_list().
SMTPs::getToken | ( | ) |
Retrieves the User token for OAUTH2.
Definition at line 948 of file smtps.class.php.
References $_smtpsToken.
SMTPs::getTrackId | ( | ) |
SMTPs::getTransEncode | ( | ) |
Retrieves the Content-Transfer-Encoding.
Definition at line 1004 of file smtps.class.php.
References $_smtpsTransEncode.
SMTPs::getTransEncodeType | ( | ) |
Retrieves the Content-Transfer-Encoding.
Definition at line 1037 of file smtps.class.php.
References $_smtpsTransEncodeType.
SMTPs::getTransportType | ( | ) |
Return the method inwhich the message is to be sent.
Definition at line 817 of file smtps.class.php.
References $_transportType.
SMTPs::getXheader | ( | ) |
Retrieves the Message X-Header Content.
Definition at line 1833 of file smtps.class.php.
References $_msgXheader.
SMTPs::sendMsg | ( | ) |
Now send the message.
Default return value
Definition at line 628 of file smtps.class.php.
SMTPs::server_parse | ( | $socket, | |
$response | |||
) |
This function has been modified as provided by SirSir to allow multiline responses when using SMTP Extensions.
resource | $socket | Socket handler |
string | $response | Response. Example: "550 5.7.1 https://support.google.com/a/answer/6140680#invalidcred j21sm814390wre.3" |
Returns constructed SELECT Object string or boolean upon failure Default value is set at true
Definition at line 1876 of file smtps.class.php.
Referenced by socket_send_str().
SMTPs::setAttachment | ( | $strContent, | |
$strFileName = 'unknown' , |
|||
$strMimeType = 'unknown' , |
|||
$strCid = '' |
|||
) |
File attachments are added to the content array as sub-arrays, allowing for multiple attachments for each outbound email.
string | $strContent | File data to attach to message |
string | $strFileName | File Name to give to attachment |
string | $strMimeType | File Mime Type of attachment |
string | $strCid | File Cid of attachment (if defined, to be shown inline) |
Definition at line 1673 of file smtps.class.php.
References dol_hash(), and getMD5flag().
SMTPs::setBCC | ( | $_strBCC | ) |
BCC Address[es] inwhich to send mail to.
string | $_strBCC | Recipients BCC Address[es] inwhich to send mail to |
Definition at line 1345 of file smtps.class.php.
References _buildAddrList().
SMTPs::setBodyContent | ( | $strContent, | |
$strType = 'plain' |
|||
) |
Message Content.
string | $strContent | Message Content |
string | $strType | Type |
Definition at line 1473 of file smtps.class.php.
References dol_hash(), and getMD5flag().
SMTPs::setCC | ( | $_strCC | ) |
CC Address[es] inwhich to send mail to.
string | $_strCC | CC Address[es] inwhich to send mail to |
Definition at line 1322 of file smtps.class.php.
References _buildAddrList().
SMTPs::setCharSet | ( | $_strCharSet | ) |
Character set used for current message Character set is defaulted to 'iso-8859-1';.
string | $_strCharSet | Character set used for current message |
Definition at line 960 of file smtps.class.php.
SMTPs::setConfig | ( | $_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.
mixed | $_strConfigPath | path to config file or VOID |
Returns constructed SELECT Object string or boolean upon failure Default value is set at true
Definition at line 756 of file smtps.class.php.
SMTPs::setDebug | ( | $_vDebug = false | ) |
Set debug.
boolean | $_vDebug | Value for debug |
Definition at line 353 of file smtps.class.php.
SMTPs::setDeliveryReceipt | ( | $_val = 0 | ) |
Set delivery receipt.
int | $_val | Value |
Definition at line 258 of file smtps.class.php.
SMTPs::setErrorsTo | ( | $_strErrorsTo | ) |
Set errors to.
string | $_strErrorsTo | Errors to |
Definition at line 321 of file smtps.class.php.
References _strip_email().
SMTPs::setFrom | ( | $_strFrom | ) |
FROM Address from which mail will be sent.
string | $_strFrom | Address from which mail will be sent |
Definition at line 1051 of file smtps.class.php.
References _strip_email().
Referenced by setConfig().
SMTPs::setHost | ( | $_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 | $_strHost | Host Name or IP of the Mail Server to use |
Definition at line 845 of file smtps.class.php.
Referenced by setConfig().
SMTPs::setID | ( | $_strID | ) |
User Name for authentication on Mail Server.
string | $_strID | User Name for authentication on Mail Server |
Definition at line 896 of file smtps.class.php.
SMTPs::setImageInline | ( | $strContent, | |
$strImageName = 'unknown' , |
|||
$strMimeType = 'unknown' , |
|||
$strImageCid = 'unknown' |
|||
) |
Image attachments are added to the content array as sub-arrays, allowing for multiple images for each outbound email.
string | $strContent | Image data to attach to message |
string | $strImageName | Image Name to give to attachment |
string | $strMimeType | Image Mime Type of attachment |
string | $strImageCid | CID |
Definition at line 1702 of file smtps.class.php.
References dol_hash(), and getMD5flag().
SMTPs::setMailPath | ( | $_path | ) |
Path to the sendmail execuable.
string | $_path | Path to the sendmail execuable |
Definition at line 829 of file smtps.class.php.
SMTPs::setMD5flag | ( | $_flag = false | ) |
Set flag which determines whether to calculate message MD5 checksum.
string | $_flag | Message Priority |
Definition at line 1798 of file smtps.class.php.
SMTPs::setMoreInHeader | ( | $_val = '' | ) |
Set moreInHeader.
string | $_val | Value |
Definition at line 290 of file smtps.class.php.
SMTPs::setOptions | ( | $_options = array() | ) |
Set delivery receipt.
array | $_options | An array of options for stream_context_create() |
Definition at line 247 of file smtps.class.php.
References $_options.
SMTPs::setPort | ( | $_intPort | ) |
Defines the Port Number of the Mail Server to use This is defaulted to '25' This is used only with 'socket' based mail transmission.
int | $_intPort | Port Number of the Mail Server to use |
Definition at line 871 of file smtps.class.php.
Referenced by setConfig().
SMTPs::setPriority | ( | $_value = 3 | ) |
Message Content Priority Message Priority values:
integer | $_value | Message Priority |
Definition at line 1765 of file smtps.class.php.
SMTPs::setPW | ( | $_strPW | ) |
User Password for authentication on Mail Server.
string | $_strPW | User Password for authentication on Mail Server |
Definition at line 917 of file smtps.class.php.
SMTPs::setReplyTo | ( | $_strReplyTo | ) |
Reply-To Address from which mail will be the reply-to.
string | $_strReplyTo | Address from which mail will be the reply-to |
Definition at line 1083 of file smtps.class.php.
References _strip_email().
SMTPs::setSensitivity | ( | $_value = 0 | ) |
Message Content Sensitivity Message Sensitivity values:
integer | $_value | Message Sensitivity |
Definition at line 1729 of file smtps.class.php.
SMTPs::setSubject | ( | $_strSubject = '' | ) |
Message Subject.
string | $_strSubject | Message Subject |
Definition at line 1368 of file smtps.class.php.
SMTPs::setTO | ( | $_addrTo | ) |
TO Address[es] inwhich to send mail to.
string | $_addrTo | TO Address[es] inwhich to send mail to |
Definition at line 1299 of file smtps.class.php.
References _buildAddrList().
SMTPs::setToken | ( | $_strToken | ) |
User token for OAUTH2.
string | $_strToken | User token |
Definition at line 938 of file smtps.class.php.
SMTPs::setTrackId | ( | $_val = '' | ) |
Set trackid.
string | $_val | Value |
Definition at line 279 of file smtps.class.php.
SMTPs::setTransEncode | ( | $_strTransEncode | ) |
Content-Transfer-Encoding, Defaulted to '7bit' This can be changed for 2byte characers sets Known Encode Types.
string | $_strTransEncode | Content-Transfer-Encoding |
Definition at line 992 of file smtps.class.php.
SMTPs::setTransEncodeType | ( | $_strTransEncodeType | ) |
Content-Transfer-Encoding, Defaulted to '0' [ZERO] This can be changed for 2byte characers sets Known Encode Types.
string | $_strTransEncodeType | Content-Transfer-Encoding |
Definition at line 1025 of file smtps.class.php.
SMTPs::setTransportType | ( | $_type = 0 | ) |
Determines the method inwhich the messages are to be sent.
int | $_type | Interger value representing Mail Transport Type |
Definition at line 802 of file smtps.class.php.
SMTPs::setXheader | ( | $strXdata | ) |
Message X-Header Content This is a simple "insert".
Whatever is given will be placed "as is" into the Xheader array.
string | $strXdata | Message X-Header Content |
Definition at line 1821 of file smtps.class.php.
SMTPs::socket_send_str | ( | $_strSend, | |
$_returnCode = null , |
|||
$CRLF = "\r\n" |
|||
) |
Send str.
string | $_strSend | String to send |
string | $_returnCode | Return code |
string | $CRLF | CRLF |
Definition at line 1917 of file smtps.class.php.
References server_parse().
|
private |
SMTP Server Port definition.
25 is default value This can be defined via a INI file or via a setter method
Definition at line 57 of file smtps.class.php.
Referenced by getPort().
|
private |
Determines the method inwhich the message are to be sent.
Definition at line 191 of file smtps.class.php.
Referenced by getTransportType().