-
Notifications
You must be signed in to change notification settings - Fork 0
CI_Email
CodeIgniter Email Class
Permits email to be sent using Mail, Sendmail, or SMTP.
- Class name: CI_Email
- Namespace:
public string $useragent = 'CodeIgniter'
Used as the User-Agent and X-Mailer headers' value.
- Visibility: public
public string $mailpath = '/usr/sbin/sendmail'
Path to the Sendmail binary.
- Visibility: public
public string $protocol = 'mail'
Which method to use for sending e-mails.
- Visibility: public
public string $smtp_host = ''
STMP Server host
- Visibility: public
public string $smtp_user = ''
SMTP Username
- Visibility: public
public string $smtp_pass = ''
SMTP Password
- Visibility: public
public integer $smtp_port = 25
SMTP Server port
- Visibility: public
public integer $smtp_timeout = 5
SMTP connection timeout in seconds
- Visibility: public
public boolean $smtp_keepalive = FALSE
SMTP persistent connection
- Visibility: public
public string $smtp_crypto = ''
SMTP Encryption
- Visibility: public
public boolean $wordwrap = TRUE
Whether to apply word-wrapping to the message body.
- Visibility: public
public integer $wrapchars = 76
Number of characters to wrap at.
- Visibility: public
public string $mailtype = 'text'
Message format.
- Visibility: public
public string $charset = 'utf-8'
Character set (default: utf-8)
- Visibility: public
public string $multipart = 'mixed'
Multipart message
- Visibility: public
public string $alt_message = ''
Alternative message (for HTML messages only)
- Visibility: public
public boolean $validate = FALSE
Whether to validate e-mail addresses.
- Visibility: public
public integer $priority = 3
X-Priority header value.
- Visibility: public
public string $newline = "\n"
Newline character sequence.
Use "\r\n" to comply with RFC 822.
- Visibility: public
public string $crlf = "\n"
CRLF character sequence
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.
- Visibility: public
public boolean $dsn = FALSE
Whether to use Delivery Status Notification.
- Visibility: public
public boolean $send_multipart = TRUE
Whether to send multipart alternatives.
Yahoo! doesn't seem to like these.
- Visibility: public
public boolean $bcc_batch_mode = FALSE
Whether to send messages to BCC recipients in batches.
- Visibility: public
public integer $bcc_batch_size = 200
BCC Batch max number size.
- Visibility: public
protected boolean $_safe_mode = FALSE
Whether PHP is running in safe mode. Initialized by the class constructor.
- Visibility: protected
protected string $_subject = ''
Subject header
- Visibility: protected
protected string $_body = ''
Message body
- Visibility: protected
protected string $_finalbody = ''
Final message body to be sent.
- Visibility: protected
protected string $_alt_boundary = ''
multipart/alternative boundary
- Visibility: protected
protected string $_atc_boundary = ''
Attachment boundary
- Visibility: protected
protected string $_header_str = ''
Final headers to send
- Visibility: protected
protected resource $_smtp_connect = ''
SMTP Connection socket placeholder
- Visibility: protected
protected string $_encoding = '8bit'
Mail encoding
- Visibility: protected
protected boolean $_smtp_auth = FALSE
Whether to perform SMTP authentication
- Visibility: protected
protected boolean $_replyto_flag = FALSE
Whether to send a Reply-To header
- Visibility: protected
protected string $_debug_msg = array()
Debug messages
- Visibility: protected
protected array<mixed,string> $_recipients = array()
Recipients
- Visibility: protected
protected array<mixed,string> $_cc_array = array()
CC Recipients
- Visibility: protected
protected array<mixed,string> $_bcc_array = array()
BCC Recipients
- Visibility: protected
protected array<mixed,string> $_headers = array()
Message headers
- Visibility: protected
protected array $_attachments = array()
Attachment data
- Visibility: protected
protected array<mixed,string> $_protocols = array('mail', 'sendmail', 'smtp')
Valid $protocol values
- Visibility: protected
protected array<mixed,string> $_base_charsets = array('us-ascii', 'iso-2022-')
Base charsets
Character sets valid for 7-bit encoding, excluding language suffix.
- Visibility: protected
protected array<mixed,string> $_bit_depths = array('7bit', '8bit')
Bit depths
Valid mail encodings
- Visibility: protected
protected array<mixed,string> $_priorities = array(1 => '1 (Highest)', 2 => '2 (High)', 3 => '3 (Normal)', 4 => '4 (Low)', 5 => '5 (Lowest)')
$priority translations
Actual values to send with the X-Priority header
- Visibility: protected
void CI_Email::__construct(array $config)
Constructor - Sets Email Preferences
The constructor can be passed an array of config values
- Visibility: public
- $config array - <p>= array()</p>
void CI_Email::__destruct()
Destructor - Releases Resources
- Visibility: public
\CI_Email CI_Email::initialize($config)
Initialize preferences
- Visibility: public
- $config mixed
\CI_Email CI_Email::clear($clear_attachments)
Initialize the Email Data
- Visibility: public
- $clear_attachments mixed
\CI_Email CI_Email::from(string $from, string $name, string $return_path)
Set FROM
- Visibility: public
- $from string
- $name string
- $return_path string - <p>= NULL Return-Path</p>
\CI_Email CI_Email::reply_to($replyto, $name)
Set Reply-to
- Visibility: public
- $replyto mixed
- $name mixed
\CI_Email CI_Email::to($to)
Set Recipients
- Visibility: public
- $to mixed
\CI_Email CI_Email::cc($cc)
Set CC
- Visibility: public
- $cc mixed
\CI_Email CI_Email::bcc($bcc, $limit)
Set BCC
- Visibility: public
- $bcc mixed
- $limit mixed
\CI_Email CI_Email::subject($subject)
Set Email Subject
- Visibility: public
- $subject mixed
\CI_Email CI_Email::message($body)
Set Body
- Visibility: public
- $body mixed
\CI_Email CI_Email::attach(string $file, string $disposition, string $newname, string $mime)
Assign file attachments
- Visibility: public
- $file string - <p>Can be local path, URL or buffered content</p>
- $disposition string - <p>= 'attachment'</p>
- $newname string - <p>= NULL</p>
- $mime string - <p>= ''</p>
string CI_Email::attachment_cid(string $filename)
Set and return attachment Content-ID
Useful for attached inline pictures
- Visibility: public
- $filename string
void CI_Email::set_header($header, $value)
Add a Header Item
- Visibility: public
- $header mixed
- $value mixed
array CI_Email::_str_to_array($email)
Convert a String to an Array
- Visibility: protected
- $email mixed
\CI_Email CI_Email::set_alt_message($str)
Set Multipart Value
- Visibility: public
- $str mixed
\CI_Email CI_Email::set_mailtype($type)
Set Mailtype
- Visibility: public
- $type mixed
\CI_Email CI_Email::set_wordwrap($wordwrap)
Set Wordwrap
- Visibility: public
- $wordwrap mixed
\CI_Email CI_Email::set_protocol($protocol)
Set Protocol
- Visibility: public
- $protocol mixed
\CI_Email CI_Email::set_priority($n)
Set Priority
- Visibility: public
- $n mixed
\CI_Email CI_Email::set_newline($newline)
Set Newline Character
- Visibility: public
- $newline mixed
\CI_Email CI_Email::set_crlf($crlf)
Set CRLF
- Visibility: public
- $crlf mixed
void CI_Email::_set_boundaries()
Set Message Boundary
- Visibility: protected
string CI_Email::_get_message_id()
Get the Message ID
- Visibility: protected
mixed CI_Email::_get_protocol($return)
Get Mail Protocol
- Visibility: protected
- $return mixed
string CI_Email::_get_encoding($return)
Get Mail Encoding
- Visibility: protected
- $return mixed
string CI_Email::_get_content_type()
Get content type (text/html/attachment)
- Visibility: protected
string CI_Email::_set_date()
Set RFC 822 Date
- Visibility: protected
string CI_Email::_get_mime_message()
Mime message
- Visibility: protected
boolean CI_Email::validate_email($email)
Validate Email Address
- Visibility: public
- $email mixed
boolean CI_Email::valid_email($email)
Email Validation
- Visibility: public
- $email mixed
string CI_Email::clean_email($email)
Clean Extended Email Address: Joe Smith [email protected]
- Visibility: public
- $email mixed
string CI_Email::_get_alt_message()
Build alternative plain text message
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
- Visibility: protected
string CI_Email::word_wrap($str, $charlim)
Word Wrap
- Visibility: public
- $str mixed
- $charlim mixed
string CI_Email::_build_headers()
Build final headers
- Visibility: protected
void CI_Email::_write_headers()
Write Headers as a string
- Visibility: protected
boolean CI_Email::_build_message()
Build Final Body and attachments
- Visibility: protected
string CI_Email::_prep_quoted_printable($str)
Prep Quoted Printable
Prepares string for Quoted-Printable Content-Transfer-Encoding Refer to RFC 2045 http://www.ietf.org/rfc/rfc2045.txt
- Visibility: protected
- $str mixed
string CI_Email::_prep_q_encoding($str)
Prep Q Encoding
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.
- Visibility: protected
- $str mixed
boolean CI_Email::send(boolean $auto_clear)
Send Email
- Visibility: public
- $auto_clear boolean - <p>= TRUE</p>
void CI_Email::batch_bcc_send()
Batch Bcc Send. Sends groups of BCCs in batches
- Visibility: public
void CI_Email::_unwrap_specials()
Unwrap special elements
- Visibility: protected
string CI_Email::_remove_nl_callback(string $matches)
Strip line-breaks via callback
- Visibility: protected
- $matches string
boolean CI_Email::_spool_email()
Spool mail to the mail server
- Visibility: protected
boolean CI_Email::_send_with_mail()
Send using mail()
- Visibility: protected
boolean CI_Email::_send_with_sendmail()
Send using Sendmail
- Visibility: protected
boolean CI_Email::_send_with_smtp()
Send using SMTP
- Visibility: protected
string CI_Email::_smtp_connect()
SMTP Connect
- Visibility: protected
string CI_Email::_send_command($cmd, $data)
Send SMTP command
- Visibility: protected
- $cmd mixed
- $data mixed
boolean CI_Email::_smtp_authenticate()
SMTP Authenticate
- Visibility: protected
boolean CI_Email::_send_data(string $data)
Send SMTP data
- Visibility: protected
- $data string
string CI_Email::_get_smtp_data()
Get SMTP data
- Visibility: protected
string CI_Email::_get_hostname()
Get Hostname
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]").
- Visibility: protected
string CI_Email::print_debugger(array $include)
Get Debug Message
- Visibility: public
- $include array - <p>List of raw data chunks to include in the output Valid options are: 'headers', 'subject', 'body'</p>
void CI_Email::_set_error_message(string $msg, string $val)
Set Message
- Visibility: protected
- $msg string
- $val string - <p>= ''</p>
string CI_Email::_mime_types($ext)
Mime Types
- Visibility: protected
- $ext mixed