PHP Class CI_Email, TastyIgniter

Permits email to be sent using Mail, Sendmail, or SMTP.
Afficher le fichier Open project: tastyigniter/tastyigniter Class Usage Examples

Méthodes publiques

Свойство Type Description
$alt_message string Alternative message (for HTML messages only)
$bcc_batch_mode boolean Whether to send messages to BCC recipients in batches.
$bcc_batch_size integer BCC Batch max number size.
$charset string Character set (default: utf-8)
$crlf string RFC 2045 specifies that for 'quoted-printable' encoding, "\r\n" must be used. However, it appears that some servers (even on the receiving end) don't handle it properly and switching to "\n", while improper, is the only solution that seems to work for all environments.
$dsn boolean Whether to use Delivery Status Notification.
$mailpath string Path to the Sendmail binary.
$mailtype Message format.
$multipart Multipart message
$newline Use "\r\n" to comply with RFC 822.
$priority X-Priority header value.
$protocol Which method to use for sending e-mails.
$send_multipart boolean Yahoo! doesn't seem to like these.
$smtp_crypto SMTP Encryption
$smtp_host string STMP Server host
$smtp_keepalive boolean SMTP persistent connection
$smtp_pass string SMTP Password
$smtp_port integer SMTP Server port
$smtp_timeout integer SMTP connection timeout in seconds
$smtp_user string SMTP Username
$useragent string Used as the User-Agent and X-Mailer headers' value.
$validate boolean Whether to validate e-mail addresses.
$wordwrap boolean Whether to apply word-wrapping to the message body.
$wrapchars integer Number of characters to wrap at.

Protected Properties

Свойство Type Description
$_alt_boundary string multipart/alternative boundary
$_atc_boundary string Attachment boundary
$_attachments array Attachment data
$_base_charsets string[] Character sets valid for 7-bit encoding, excluding language suffix.
$_bcc_array string[] BCC Recipients
$_bit_depths string[] Valid mail encodings
$_body string Message body
$_cc_array string[] CC Recipients
$_debug_msg string Debug messages
$_encoding Mail encoding
$_finalbody string Final message body to be sent.
$_header_str string Final headers to send
$_headers string[] Message headers
$_priorities string[] Actual values to send with the X-Priority header
$_protocols string[] Valid $protocol values
$_recipients string[] Recipients
$_replyto_flag boolean Whether to send a Reply-To header
$_safe_mode boolean Whether PHP is running in safe mode. Initialized by the class constructor.
$_smtp_auth boolean Whether to perform SMTP authentication
$_smtp_connect resource SMTP Connection socket placeholder
$_subject string Subject header

Méthodes publiques

Méthode Description
__construct ( array $config = [] ) : void Constructor - Sets Email Preferences
__destruct ( ) : void Destructor - Releases Resources
attach ( string $file, string $disposition = '', string $newname = NULL, string $mime = '' ) : CI_Email Assign file attachments
attachment_cid ( string $filename ) : string Set and return attachment Content-ID
batch_bcc_send ( ) : void Batch Bcc Send. Sends groups of BCCs in batches
bcc ( $bcc, $limit = '' ) : CI_Email Set BCC
cc ( $cc ) : CI_Email Set CC
clean_email ( $email ) : string Clean Extended Email Address: Joe Smith
clear ( $clear_attachments = FALSE ) : CI_Email Initialize the Email Data
from ( string $from, string $name = '', string $return_path = NULL ) : CI_Email Set FROM
initialize ( $config = [] ) : CI_Email Initialize preferences
message ( $body ) : CI_Email Set Body
print_debugger ( array $include = ['headers', 'subject', 'body'] ) : string Get Debug Message
reply_to ( $replyto, $name = '' ) : CI_Email Set Reply-to
send ( boolean $auto_clear = TRUE ) : boolean Send Email
set_alt_message ( $str ) : CI_Email Set Multipart Value
set_crlf ( $crlf = " " ) : CI_Email Set CRLF
set_header ( $header, $value ) : CI_Email Add a Header Item
set_mailtype ( $type = 'text' ) : CI_Email Set Mailtype
set_newline ( $newline = " " ) : CI_Email Set Newline Character
set_priority ( $n = 3 ) : CI_Email Set Priority
set_protocol ( $protocol = 'mail' ) : CI_Email Set Protocol
set_wordwrap ( $wordwrap = TRUE ) : CI_Email Set Wordwrap
subject ( $subject ) : CI_Email Set Email Subject
to ( $to ) : CI_Email Set Recipients
valid_email ( $email ) : boolean Email Validation
validate_email ( $email ) : boolean Validate Email Address
word_wrap ( $str, $charlim = NULL ) : string Word Wrap

Méthodes protégées

Méthode Description
_build_headers ( ) : string Build final headers
_build_message ( ) : boolean Build Final Body and attachments
_get_alt_message ( ) : string Build alternative plain text message
_get_content_type ( ) : string Get content type (text/html/attachment)
_get_encoding ( $return = TRUE ) : string Get Mail Encoding
_get_hostname ( ) : string Get Hostname
_get_message_id ( ) : string Get the Message ID
_get_mime_message ( ) : string Mime message
_get_protocol ( $return = TRUE ) : mixed Get Mail Protocol
_get_smtp_data ( ) : string Get SMTP data
_mime_types ( $ext = '' ) : string Mime Types
_prep_q_encoding ( $str ) : string Prep Q Encoding
_prep_quoted_printable ( $str ) : string Prep Quoted Printable
_remove_nl_callback ( string $matches ) : string Strip line-breaks via callback
_send_command ( $cmd, $data = '' ) : string Send SMTP command
_send_data ( string $data ) : boolean Send SMTP data
_send_with_mail ( ) : boolean Send using mail()
_send_with_sendmail ( ) : boolean Send using Sendmail
_send_with_smtp ( ) : boolean Send using SMTP
_set_boundaries ( ) : void Set Message Boundary
_set_date ( ) : string Set RFC 822 Date
_set_error_message ( string $msg, string $val = '' ) : void Set Message
_smtp_authenticate ( ) : boolean SMTP Authenticate
_smtp_connect ( ) : string SMTP Connect
_spool_email ( ) : boolean Spool mail to the mail server
_str_to_array ( $email ) : array Convert a String to an Array
_unwrap_specials ( ) : void Unwrap special elements
_write_headers ( ) : void Write Headers as a string

Method Details

__construct() public méthode

The constructor can be passed an array of config values
public __construct ( array $config = [] ) : void
$config array = array()
Résultat void

__destruct() public méthode

Destructor - Releases Resources
public __destruct ( ) : void
Résultat void

_build_headers() protected méthode

Build final headers
protected _build_headers ( ) : string
Résultat string

_build_message() protected méthode

Build Final Body and attachments
protected _build_message ( ) : boolean
Résultat boolean

_get_alt_message() protected méthode

Provides the raw message for use in plain-text headers of HTML-formatted emails. If the user hasn't specified his own alternative message it creates one by stripping the HTML
protected _get_alt_message ( ) : string
Résultat string

_get_content_type() protected méthode

Get content type (text/html/attachment)
protected _get_content_type ( ) : string
Résultat string

_get_encoding() protected méthode

Get Mail Encoding
protected _get_encoding ( $return = TRUE ) : string
Résultat string

_get_hostname() protected méthode

There are only two legal types of hostname - either a fully qualified domain name (eg: "mail.example.com") or an IP literal (eg: "[1.2.3.4]").
protected _get_hostname ( ) : string
Résultat string

_get_message_id() protected méthode

Get the Message ID
protected _get_message_id ( ) : string
Résultat string

_get_mime_message() protected méthode

Mime message
protected _get_mime_message ( ) : string
Résultat string

_get_protocol() protected méthode

Get Mail Protocol
protected _get_protocol ( $return = TRUE ) : mixed
Résultat mixed

_get_smtp_data() protected méthode

Get SMTP data
protected _get_smtp_data ( ) : string
Résultat string

_mime_types() protected méthode

Mime Types
protected _mime_types ( $ext = '' ) : string
Résultat string

_prep_q_encoding() protected méthode

Performs "Q Encoding" on a string for use in email headers. It's related but not identical to quoted-printable, so it has its own method.
protected _prep_q_encoding ( $str ) : string
Résultat string

_prep_quoted_printable() protected méthode

Prepares string for Quoted-Printable Content-Transfer-Encoding Refer to RFC 2045 http://www.ietf.org/rfc/rfc2045.txt
protected _prep_quoted_printable ( $str ) : string
Résultat string

_remove_nl_callback() protected méthode

Strip line-breaks via callback
protected _remove_nl_callback ( string $matches ) : string
$matches string
Résultat string

_send_command() protected méthode

Send SMTP command
protected _send_command ( $cmd, $data = '' ) : string
Résultat string

_send_data() protected méthode

Send SMTP data
protected _send_data ( string $data ) : boolean
$data string
Résultat boolean

_send_with_mail() protected méthode

Send using mail()
protected _send_with_mail ( ) : boolean
Résultat boolean

_send_with_sendmail() protected méthode

Send using Sendmail
protected _send_with_sendmail ( ) : boolean
Résultat boolean

_send_with_smtp() protected méthode

Send using SMTP
protected _send_with_smtp ( ) : boolean
Résultat boolean

_set_boundaries() protected méthode

Set Message Boundary
protected _set_boundaries ( ) : void
Résultat void

_set_date() protected méthode

Set RFC 822 Date
protected _set_date ( ) : string
Résultat string

_set_error_message() protected méthode

Set Message
protected _set_error_message ( string $msg, string $val = '' ) : void
$msg string
$val string = ''
Résultat void

_smtp_authenticate() protected méthode

SMTP Authenticate
protected _smtp_authenticate ( ) : boolean
Résultat boolean

_smtp_connect() protected méthode

SMTP Connect
protected _smtp_connect ( ) : string
Résultat string

_spool_email() protected méthode

Spool mail to the mail server
protected _spool_email ( ) : boolean
Résultat boolean

_str_to_array() protected méthode

Convert a String to an Array
protected _str_to_array ( $email ) : array
Résultat array

_unwrap_specials() protected méthode

Unwrap special elements
protected _unwrap_specials ( ) : void
Résultat void

_write_headers() protected méthode

Write Headers as a string
protected _write_headers ( ) : void
Résultat void

attach() public méthode

Assign file attachments
public attach ( string $file, string $disposition = '', string $newname = NULL, string $mime = '' ) : CI_Email
$file string Can be local path, URL or buffered content
$disposition string = 'attachment'
$newname string = NULL
$mime string = ''
Résultat CI_Email

attachment_cid() public méthode

Useful for attached inline pictures
public attachment_cid ( string $filename ) : string
$filename string
Résultat string

batch_bcc_send() public méthode

Batch Bcc Send. Sends groups of BCCs in batches
public batch_bcc_send ( ) : void
Résultat void

bcc() public méthode

Set BCC
public bcc ( $bcc, $limit = '' ) : CI_Email
Résultat CI_Email

cc() public méthode

Set CC
public cc ( $cc ) : CI_Email
Résultat CI_Email

clean_email() public méthode

Clean Extended Email Address: Joe Smith
public clean_email ( $email ) : string
Résultat string

clear() public méthode

Initialize the Email Data
public clear ( $clear_attachments = FALSE ) : CI_Email
Résultat CI_Email

from() public méthode

Set FROM
public from ( string $from, string $name = '', string $return_path = NULL ) : CI_Email
$from string
$name string
$return_path string = NULL Return-Path
Résultat CI_Email

initialize() public méthode

Initialize preferences
public initialize ( $config = [] ) : CI_Email
Résultat CI_Email

message() public méthode

Set Body
public message ( $body ) : CI_Email
Résultat CI_Email

print_debugger() public méthode

Get Debug Message
public print_debugger ( array $include = ['headers', 'subject', 'body'] ) : string
$include array List of raw data chunks to include in the output Valid options are: 'headers', 'subject', 'body'
Résultat string

reply_to() public méthode

Set Reply-to
public reply_to ( $replyto, $name = '' ) : CI_Email
Résultat CI_Email

send() public méthode

Send Email
public send ( boolean $auto_clear = TRUE ) : boolean
$auto_clear boolean = TRUE
Résultat boolean

set_alt_message() public méthode

Set Multipart Value
public set_alt_message ( $str ) : CI_Email
Résultat CI_Email

set_crlf() public méthode

Set CRLF
public set_crlf ( $crlf = " " ) : CI_Email
Résultat CI_Email

set_header() public méthode

Add a Header Item
public set_header ( $header, $value ) : CI_Email
Résultat CI_Email

set_mailtype() public méthode

Set Mailtype
public set_mailtype ( $type = 'text' ) : CI_Email
Résultat CI_Email

set_newline() public méthode

Set Newline Character
public set_newline ( $newline = " " ) : CI_Email
Résultat CI_Email

set_priority() public méthode

Set Priority
public set_priority ( $n = 3 ) : CI_Email
Résultat CI_Email

set_protocol() public méthode

Set Protocol
public set_protocol ( $protocol = 'mail' ) : CI_Email
Résultat CI_Email

set_wordwrap() public méthode

Set Wordwrap
public set_wordwrap ( $wordwrap = TRUE ) : CI_Email
Résultat CI_Email

subject() public méthode

Set Email Subject
public subject ( $subject ) : CI_Email
Résultat CI_Email

to() public méthode

Set Recipients
public to ( $to ) : CI_Email
Résultat CI_Email

valid_email() public méthode

Email Validation
public valid_email ( $email ) : boolean
Résultat boolean

validate_email() public méthode

Validate Email Address
public validate_email ( $email ) : boolean
Résultat boolean

word_wrap() public méthode

Word Wrap
public word_wrap ( $str, $charlim = NULL ) : string
Résultat string

Property Details

$_alt_boundary protected_oe property

multipart/alternative boundary
protected string $_alt_boundary
Résultat string

$_atc_boundary protected_oe property

Attachment boundary
protected string $_atc_boundary
Résultat string

$_attachments protected_oe property

Attachment data
protected array $_attachments
Résultat array

$_base_charsets protected_oe property

Character sets valid for 7-bit encoding, excluding language suffix.
protected string[] $_base_charsets
Résultat string[]

$_bcc_array protected_oe property

BCC Recipients
protected string[] $_bcc_array
Résultat string[]

$_bit_depths protected_oe property

Valid mail encodings
See also: CI_Email::$_encoding
protected string[] $_bit_depths
Résultat string[]

$_body protected_oe property

Message body
protected string $_body
Résultat string

$_cc_array protected_oe property

CC Recipients
protected string[] $_cc_array
Résultat string[]

$_debug_msg protected_oe property

Debug messages
See also: CI_Email::print_debugger()
protected string $_debug_msg
Résultat string

$_encoding protected_oe property

Mail encoding
protected $_encoding

$_finalbody protected_oe property

Final message body to be sent.
protected string $_finalbody
Résultat string

$_header_str protected_oe property

Final headers to send
protected string $_header_str
Résultat string

$_headers protected_oe property

Message headers
protected string[] $_headers
Résultat string[]

$_priorities protected_oe property

Actual values to send with the X-Priority header
protected string[] $_priorities
Résultat string[]

$_protocols protected_oe property

Valid $protocol values
See also: CI_Email::$protocol
protected string[] $_protocols
Résultat string[]

$_recipients protected_oe property

Recipients
protected string[] $_recipients
Résultat string[]

$_replyto_flag protected_oe property

Whether to send a Reply-To header
protected bool $_replyto_flag
Résultat boolean

$_safe_mode protected_oe property

Whether PHP is running in safe mode. Initialized by the class constructor.
protected bool $_safe_mode
Résultat boolean

$_smtp_auth protected_oe property

Whether to perform SMTP authentication
protected bool $_smtp_auth
Résultat boolean

$_smtp_connect protected_oe property

SMTP Connection socket placeholder
protected resource $_smtp_connect
Résultat resource

$_subject protected_oe property

Subject header
protected string $_subject
Résultat string

$alt_message public_oe property

Alternative message (for HTML messages only)
public string $alt_message
Résultat string

$bcc_batch_mode public_oe property

Whether to send messages to BCC recipients in batches.
public bool $bcc_batch_mode
Résultat boolean

$bcc_batch_size public_oe property

BCC Batch max number size.
See also: CI_Email::$bcc_batch_mode
public int $bcc_batch_size
Résultat integer

$charset public_oe property

Character set (default: utf-8)
public string $charset
Résultat string

$crlf public_oe property

RFC 2045 specifies that for 'quoted-printable' encoding, "\r\n" must be used. However, it appears that some servers (even on the receiving end) don't handle it properly and switching to "\n", while improper, is the only solution that seems to work for all environments.
public string $crlf
Résultat string

$dsn public_oe property

Whether to use Delivery Status Notification.
public bool $dsn
Résultat boolean

$mailpath public_oe property

Path to the Sendmail binary.
public string $mailpath
Résultat string

$mailtype public_oe property

Message format.
public $mailtype

$multipart public_oe property

Multipart message
public $multipart

$newline public_oe property

Use "\r\n" to comply with RFC 822.
public $newline

$priority public_oe property

X-Priority header value.
public $priority

$protocol public_oe property

Which method to use for sending e-mails.
public $protocol

$send_multipart public_oe property

Yahoo! doesn't seem to like these.
public bool $send_multipart
Résultat boolean

$smtp_crypto public_oe property

SMTP Encryption
public $smtp_crypto

$smtp_host public_oe property

STMP Server host
public string $smtp_host
Résultat string

$smtp_keepalive public_oe property

SMTP persistent connection
public bool $smtp_keepalive
Résultat boolean

$smtp_pass public_oe property

SMTP Password
public string $smtp_pass
Résultat string

$smtp_port public_oe property

SMTP Server port
public int $smtp_port
Résultat integer

$smtp_timeout public_oe property

SMTP connection timeout in seconds
public int $smtp_timeout
Résultat integer

$smtp_user public_oe property

SMTP Username
public string $smtp_user
Résultat string

$useragent public_oe property

Used as the User-Agent and X-Mailer headers' value.
public string $useragent
Résultat string

$validate public_oe property

Whether to validate e-mail addresses.
public bool $validate
Résultat boolean

$wordwrap public_oe property

Whether to apply word-wrapping to the message body.
public bool $wordwrap
Résultat boolean

$wrapchars public_oe property

Number of characters to wrap at.
See also: CI_Email::$wordwrap
public int $wrapchars
Résultat integer