Smart.Framework Logo

final class \SmartMailerSend
{ } ->

Class: SmartMailerSend - provides a Mail Send Client that supports both: MAIL or SMTP with SSL/TLS support.
It automatically includes the SmartMailerSmtpClient class when sending via SMTP method.
This class is a low level message composer and send utility for advanced usage.


class Methods

public function __construct ( ) {} @ 
Class constructor
public function send ( ENUM $do_send, STRING $raw_message = "" ) {} -> STRING
@return: {STRING} Empty string if SUCCESS or Error Message on FAILURE ; Failure may come as missing some required message compose properties and/or if send = 'yes' will also check the email send success ; NOTICE: if using MAIL method the mail send result may report or not an error ... ; With SMTP sending the message assure it is delivered to the destination SMTP server with or without an error
@param: {ENUM} $do_send: If set to 'yes' will do send the message using MAIL or SMTP method depend how this class is set ; If set to 'no' will just compose a message from provided parameters ; does not apply if $raw_message is supplied ...
@param: {STRING} $raw_message: If this is provided will use the message from this string and will not compose the message using this class properties: $subject, $body, $headers, $from, $to, $cc, $bcc, ...
Compose and/or Send an Email Message using MAIL or SMTP method, depend how this class properties are set
If the 2nd parameter is empty as '', the composed message can be retrieved by reading the (string) $class->mime_message property after calling this function
Can be a Text or HTML Message
public function add_attachment ( STRING $att_body, STRING $name = "", ENUM $ctype = "", ENUM $disp = "attachment", STRING $cid = "", ENUM $embed = "no" ) {} -> BOOLEAN
@return: {BOOLEAN} On Success will return TRUE, on Failure will return FALSE
@param: {STRING} $att_body: The body of the attachment
@param: {STRING} $name: *Optional* A File Name for this attachment
@param: {ENUM} $ctype: *Optional* The content type of the attachment: 'text/plain', 'text/html', 'message/rfc822', 'application/octet-stream'
@param: {ENUM} $disp: *Optional* The content disposition of the attachment: 'inline' or 'attachment' ; if $ctype is 'application/octet-stream' can be only 'attachment'
@param: {STRING} $cid: *Optional* The content ID if using with linked HTML reference parts of the message HTML body
@param: {ENUM} $embed: *Optional* If set to 'yes' will embed this part as real attachment ; else will embedd it as message sub-part ; Chossing this depends pretty much on how the message is built, if there are linked sub-parts or not ... too much philosophy to explain all here, but all the documentation for MIME E-mail Encapsulation of Aggregate Parts is here: https://tools.ietf.org/html/rfc2110
Add an attachment to the message
public function safe_header_str ( STRING $str ) {} -> STRING
@return: {STRING} The safe escaped Mime Message Header Line
@param: {STRING} $str: The mime header line (MUST NOT Contain the line ending CRLF as \r\n) ; Line ending must be added after escaping the header line using this function
Provide a helper to safe escape Mime (Email) Message Header Lines
public function safe_value_str ( STRING $str ) {} -> STRING
@return: {STRING} The safe escaped Mime Message Value
@param: {STRING} $str: The mime value
Provide a helper to safe escape Mime (Email) Message Values

class Properties

public $debuglevel = 0 ;  -> INTEGER+
Debug Level
Valid values: 0 = no debug ; 1 = simple debug (partial) ; 2 = advanced debug (full)
public $error -> STRING
Errors Collector
If any error occurs will be set here
default ''
public $log -> STRING
Debug Log Collector
If Debug, this will return the partial or full Log as string, depend on how $debuglevel is set
default ''
public $usealways_b64 = TRUE ;  -> BOOLEAN
If set to TRUE will encode using Base64 Encode for Subject, Body Parts and Attachments (the most safe)
Otherwise will use Q Encode for Subject, QuotePrintable Encode for Body Parts and Base64 Encode for Attachments (the most used)
public $use_min_enc_subj = TRUE ;  -> BOOLEAN
If set to TRUE will use oportunistic encode of Subject (all or just parts) in a minimal way, using an auto algorithm to analyze it ; encode entire Subject or some parts of it ; and only if necessary ; it also may apply line wrapping on long subjects if necessary
Otherwise will use Base64 (if usealways_b64 is TRUE) or Q Encode (if usealways_b64 is FALSE)
Setting this to true may be a better choice for Anti-SPAM filters but some non-compliant email clients may not display the subjects correctly when encoded this way ...
public $use_antispam_rules = TRUE ;  -> BOOLEAN
If set to TRUE will use extra safe rules when composing email mime messages to be sent (Ex: adding alternate TEXT body to HTML email messages ; adding the X-AntiAbuse headers, ...)
Otherwise will make messages shorter by avoid embedding extra stuff that are required to better pass AntiSPAM Filters
Setting this to false may be a better choice for local messages but a bad choice for real world messages ...
public $method = 'mail' ;  -> ENUM
The Mail Method to be used
Valid values: 'mail' or 'smtp'
If 'smtp' is used, additional SMTP settings must be added to this class (see below)
public $is_html = false ;  -> BOOLEAN
If set to TRUE will send HTML formated message, otherwise Text
public $charset = 'ISO-8859-1' ;  -> STRING
Message Character Set
Ussualy should be set to 'UTF-8'
public $from_return = '' ;  -> STRING
Message Return Recipient Email Address
Ex: 'return@my-email.ext'
public $namefrom = '' ;  -> STRING
Message From Recipient Name
*Optional*
Ex: 'Me'
public $from = '' ;  -> STRING
Message From Recipient Email Address
Ex: 'me@my-email.ext'
public $to = '' ;  -> STRING
Message To Recipient Email Address
Ex: 'to@email.ext'
public $cc = '' ;  -> MIXED
Message Cc Recipient(s) Email Address(es) as STRING or ARRAY
*Optional*
Ex: 'cc@email.ext' or [ 'cc1@email.ext', 'cc2@email3.ext', ... ]
public $bcc = '' ;  -> STRING
Message Bcc Recipient Email Address
*Optional*
Ex: 'bcc@email101.ext'
public $priority = 3 ;  -> ENUM
Message Priority ; Can be (as standards): 1 = High ; 3 = Normal ; 5 = Low
*Optional*
public $subject = '' ;  -> STRING
Message Subject (max 127 characters) ; Ex: 'This is the subject of the email Message'
public $body = '' ;  -> STRING
Message Body
Ex(text): 'This is the body of the email Message\nAnd a new Line ...' $is_html should be leave as FALSE as default in this case
Ex(html): 'This is the body of the email Message<br>And a new Line ...' -> $is_html must be set to TRUE if HTML body is sent
For the case of sending HTML bodies you must assure mprogramatically that all HTML required resources as images, css, ... are embedded (the will not be embedded automatically)
As an alternative tho this class which is low level
public $headers = '' ;  -> STRING
Message Headers
*Optional*
If non-empty, each header line must be end as CRLF (\r\n)
Ex: 'X-AntiAbuse: This header was added to track abuse, please include it with any abuse report'."\r\n".'X-AntiAbuse: Sender Address Domain - mydomain.ext'."\r\n"
public $smtp_helo = 'localhost' ;  -> STRING
Apply only if send the email message using SMTP Method
SMTP HELO (server name that is allowed to send mails for this domain)
Must be set to a real domain host that is valid to send emails for that address
public $smtp_server = null ;  -> STRING
Apply only if send the email message using SMTP Method
SMTP server host or ip
public $smtp_port = null ;  -> INTEGER+
Apply only if send the email message using SMTP Method
SMTP server port ; usually 25
public $smtp_ssl = null ;  -> ENUM
Apply only if send the email message using SMTP Method
SMTP SSL Mode: '', 'starttls', 'starttls:1.0', 'starttls:1.1', 'starttls:1.2', 'tls', 'tls:1.0', 'tls:1.1', 'tls:1.2', 'ssl', 'sslv3'
If empty string will be set it will be not using SSL Mode
public $smtp_cafile = null ;  -> STRING
Apply only if send the email message using SMTP Method
Relative Path to a SSL Certificate Authority File
If SSL Mode is set this is optional, otherwise is not used
Ex: store within smart-framework/etc/certificates ; specify as 'etc/certificates/ca.pem')
IMPORTANT: in this case the 'etc/certificates/' directory must be protected with a .htaccess to avoid being public readable - the directory and any files within this directory ...
public $smtp_timeout = 30 ;  -> INTEGER+
Apply only if send the email message using SMTP Method
SMTP Connection Timeout in seconds
public $smtp_login = false ;  -> BOOLEAN
Apply only if send the email message using SMTP Method
SMTP Authentication ; If set to TRUE will try a SMTP Auth (login) using non-empty and valid $smtp_user and $smtp_password
public $smtp_user = null ;  -> STRING
Apply only if send the email message using SMTP Method
SMTP Authentication username ($smtp_login must be set to TRUE and a valid, non-empty $smtp_password must be provided)
public $smtp_password = null ;  -> STRING
Apply only if send the email message using SMTP Method
SMTP Authentication password ($smtp_login must be set to TRUE and a valid, non-empty $smtp_user must be provided)
public $smtp_modeauth = '' ;  -> ENUM
Apply only if send the email message using SMTP Method
SMTP Authentication mode ($smtp_login must be set to TRUE and a valid, non-empty $smtp_user and $smtp_password must be provided)
Can be set to any of: 'login', 'auth:plain', 'auth:cram-md5', 'auth:xoauth2' ; Default is '' which selects the default 'login'
public $mime_message = '' ;  -> STRING
Store the composed message by this class
If used with $class->send() and not using the 2nd parameter may return the mime message composed in this variable

class Constants



documentation generated on: 2023-10-19 23:15:46 +0000


Smart.Framework © 2009-2023 unix-world.org