include/phpmailer/class.phpmailer.php
\PHPMailer
- Children
- \SugarPHPMailer
Properties

string
$AltBody= ''''
Sets the text-only body of the message. This automatically sets the email to multipart/alternative. This body can be read by mail clients that do not have HTML email capability such as mutt. Clients that can read HTML will view the normal Body.
''Details- Type
- string

string
$Body= ''''
Sets the Body of the message. This can be either an HTML or text body.
If HTML then run IsHTML(true).
''Details- Type
- string

string
$ConfirmReadingTo= ''''
Sets the email address that a reading confirmation will be sent.
''Details- Type
- string

string
$ContentType= ''text/plain''
Sets the Content-type of the message.
'text/plain'Details- Type
- string

string
$Encoding= ''8bit''
Sets the Encoding of the message. Options for this are "8bit", "7bit", "binary", "base64", and "quoted-printable".
'8bit'Details- Type
- string

string
$ErrorInfo= ''''
Holds the most recent mailer error message.
''Details- Type
- string

string
$From= ''root@localhost''
Sets the From email address for the message.
'root@localhost'Details- Type
- string

string
$FromName= ''Root User''
Sets the From name of the message.
'Root User'Details- Type
- string

string
$Helo= ''''
Sets the SMTP HELO of the message (Default is $Hostname).
''Details- Type
- string

string
$Host= ''localhost''
Sets the SMTP hosts. All hosts must be separated by a semicolon. You can also specify a different port for each host by using this format: [hostname:port] (e.g. "smtp1.example.com:25;smtp2.example.com").
Hosts will be tried in order.
'localhost'Details- Type
- string

string
$Hostname= ''''
Sets the hostname to use in Message-Id and Received headers and as default HELO string. If empty, the value returned by SERVER_NAME is used or 'localhost.localdomain'.
''Details- Type
- string

string
$LE= '"\r\n"'
Provides the ability to change the line ending
"\r\n"Details- Type
- string

string
$Mailer= ''mail''
Method to send mail: ("mail", "sendmail", or "smtp").
'mail'Details- Type
- string

string
$MessageID= ''''
Sets the message ID to be used in the Message-Id header.
If empty, a unique id will be generated.
''Details- Type
- string

string
$PluginDir= ''include/phpmailer/''
Path to PHPMailer plugins. This is now only useful if the SMTP class is in a different directory than the PHP include path.
'include/phpmailer/'Details- Type
- string

bool
$SMTPAuth= 'false'
Sets SMTP authentication. Utilizes the Username and Password variables.
falseDetails- Type
- bool

bool
$SMTPKeepAlive= 'false'
Prevents the SMTP connection from being closed after each mail sending. If this is set to true then to close the connection requires an explicit call to SmtpClose().
falseDetails- Type
- bool

string
$SMTPSecure= '""'
Sets connection prefix.
Options are "", "ssl" or "tls"
""Details- Type
- string

string
$Sender= ''''
Sets the Sender email (Return-Path) of the message. If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
''Details- Type
- string

string
$Sendmail= ''/usr/sbin/sendmail''
Sets the path of the sendmail program.
'/usr/sbin/sendmail'Details- Type
- string

bool
$SingleTo= 'false'
Provides the ability to have the TO field process individual emails, instead of sending to entire TO addresses
falseDetails- Type
- bool

int
$Timeout= '10'
Sets the SMTP server timeout in seconds. This function will not work with the win32 version.
10Details- Type
- int

int
$WordWrap= '0'
Sets word wrapping on the body of the message to a given number of characters.
0Details- Type
- int
Methods

AddAddress(
string $address, string $name
=
''
)
:
voidAdds a "To" address.
| Name | Type | Description |
|---|---|---|
| $address | string | |
| $name | string |

AddAttachment(
string $path, string $name
=
'', string $encoding
=
'base64', string $type
=
'application/octet-stream'
)
:
boolAdds an attachment from a path on the filesystem.
Returns false if the file could not be found or accessed.
| Name | Type | Description |
|---|---|---|
| $path | string | Path to the attachment. |
| $name | string | Overrides the attachment name. |
| $encoding | string | File encoding (see $Encoding). |
| $type | string | File extension (MIME) type. |
| Type | Description |
|---|---|
| bool |

AddBCC(
string $address, string $name
=
''
)
:
voidAdds a "Bcc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
| Name | Type | Description |
|---|---|---|
| $address | string | |
| $name | string |

AddCC(
string $address, string $name
=
''
)
:
voidAdds a "Cc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
| Name | Type | Description |
|---|---|---|
| $address | string | |
| $name | string |

AddCustomHeader(
$custom_header
)
:
voidAdds a custom header.
| Name | Type | Description |
|---|---|---|
| $custom_header |
- Access
- public

AddEmbeddedImage(
string $path, string $cid, string $name
=
'', string $encoding
=
'base64', string $type
=
'application/octet-stream'
)
:
boolAdds an embedded attachment. This can include images, sounds, and just about any other document. Make sure to set the $type to an image type. For JPEG images use "image/jpeg" and for GIF images use "image/gif".
| Name | Type | Description |
|---|---|---|
| $path | string | Path to the attachment. |
| $cid | string | Content ID of the attachment. Use this to identify the Id for accessing the image in an HTML form. |
| $name | string | Overrides the attachment name. |
| $encoding | string | File encoding (see $Encoding). |
| $type | string | File extension (MIME) type. |
| Type | Description |
|---|---|
| bool |

AddReplyTo(
string $address, string $name
=
''
)
:
voidAdds a "Reply-to" address.
| Name | Type | Description |
|---|---|---|
| $address | string | |
| $name | string |

AddStringAttachment(
string $string, string $filename, string $encoding
=
'base64', string $type
=
'application/octet-stream'
)
:
voidAdds a string or binary attachment (non-filesystem) to the list.
This method can be used to attach ascii or binary data, such as a BLOB record from a database.
| Name | Type | Description |
|---|---|---|
| $string | string | String attachment data. |
| $filename | string | Name of the attachment. |
| $encoding | string | File encoding (see $Encoding). |
| $type | string | File extension (MIME) type. |

AddrAppend(
$type, $addr
)
:
stringCreates recipient headers.
| Name | Type | Description |
|---|---|---|
| $type | ||
| $addr |
| Type | Description |
|---|---|
| string |
- Access
- public

AddrFormat(
$addr
)
:
stringFormats an address correctly.
| Name | Type | Description |
|---|---|---|
| $addr |
| Type | Description |
|---|---|
| string |
- Access
- public

AttachAll(
)
:
stringAttaches all fs, string, and binary attachments to the message.
Returns an empty string on failure.
| Type | Description |
|---|---|
| string |
- Access
- public

Base64EncodeWrapMB(
string $str
)
:
stringCorrectly encodes and wraps long multibyte strings for mail headers without breaking lines within a character.
Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php
| Name | Type | Description |
|---|---|---|
| $str | string | multi-byte text to wrap encode |
| Type | Description |
|---|---|
| string |
- Access
- public

ClearAllRecipients(
)
:
voidClears all recipients assigned in the TO, CC and BCC array. Returns void.

ClearAttachments(
)
:
voidClears all previously set filesystem, string, and binary attachments. Returns void.

CreateBody(
)
:
stringAssembles the message body. Returns an empty string on failure.
| Type | Description |
|---|---|
| string |
- Access
- public

CreateHeader(
)
:
stringAssembles message header.
| Type | Description |
|---|---|
| string |
- Access
- public

EncodeFile(
$path, $encoding
=
'base64'
)
:
stringEncodes attachment in requested format. Returns an empty string on failure.
| Name | Type | Description |
|---|---|---|
| $path | ||
| $encoding |
| Type | Description |
|---|---|
| string |
- Access
- public

EncodeHeader(
$str, $position
=
'text'
)
:
stringEncode a header string to best of Q, B, quoted or none.
| Name | Type | Description |
|---|---|---|
| $str | ||
| $position |
| Type | Description |
|---|---|
| string |
- Access
- public

EncodeQ(
$str, $position
=
'text'
)
:
stringEncode string to q encoding.
| Name | Type | Description |
|---|---|---|
| $str | ||
| $position |
| Type | Description |
|---|---|
| string |
- Access
- public

EncodeQP(
$input
=
'', integer $line_max
=
76, $space_conv
=
false
)
:
stringEncode string to quoted-printable.
| Name | Type | Description |
|---|---|---|
| $input | ||
| $line_max | integer | Number of chars allowed on a line before wrapping |
| $space_conv |
| Type | Description |
|---|---|
| string |
- Access
- public

EncodeString(
$str, $encoding
=
'base64'
)
:
stringEncodes string to requested format. Returns an empty string on failure.
| Name | Type | Description |
|---|---|---|
| $str | ||
| $encoding |
| Type | Description |
|---|---|
| string |
- Access
- public

EndBoundary(
$boundary
)
:
voidReturns the end of a message boundary.
| Name | Type | Description |
|---|---|---|
| $boundary |
- Access
- public

FixEOL(
$str
)
:
stringChanges every end of line from CR or LF to CRLF.
| Name | Type | Description |
|---|---|---|
| $str |
| Type | Description |
|---|---|
| string |
- Access
- private

GetBoundary(
$boundary, $charSet, $contentType, $encoding
)
:
voidReturns the start of a message boundary.
| Name | Type | Description |
|---|---|---|
| $boundary | ||
| $charSet | ||
| $contentType | ||
| $encoding |
- Access
- public

GetMailMIME(
)
:
stringReturns the message MIME.
| Type | Description |
|---|---|
| string |
- Access
- public

HasMultiBytes(
string $str
)
:
boolChecks if a string contains multibyte characters.
| Name | Type | Description |
|---|---|---|
| $str | string | multi-byte text to wrap encode |
| Type | Description |
|---|---|
| bool |
- Access
- public

InlineImageExists(
)
:
boolReturns true if an inline attachment is present.
| Type | Description |
|---|---|
| bool |
- Access
- public

IsError(
)
:
boolReturns true if an error occurred.
| Type | Description |
|---|---|
| bool |
- Access
- public

Lang(
$key
)
:
stringReturns a message in the appropriate language.
| Name | Type | Description |
|---|---|---|
| $key |
| Type | Description |
|---|---|
| string |
- Access
- private

MailSend(
$header, $body
)
:
boolSends mail using the PHP mail() function.
| Name | Type | Description |
|---|---|---|
| $header | ||
| $body |
| Type | Description |
|---|---|
| bool |
- Access
- public

MsgHTML(
$message, $basedir
=
''
)
:
\$messageEvaluates the message and returns modifications for inline images and backgrounds
| Name | Type | Description |
|---|---|---|
| $message | ||
| $basedir |
| Type | Description |
|---|---|
| \$message |
- Access
- public

RFCDate(
)
:
stringReturns the proper RFC 822 formatted date.
| Type | Description |
|---|---|
| string |
- Access
- private

SecureHeader(
string $str
)
:
stringStrips newlines to prevent header injection.
| Name | Type | Description |
|---|---|---|
| $str | string | String |
| Type | Description |
|---|---|
| string |
- Access
- public

Send(
)
:
boolCreates message and assigns Mailer. If the message is not sent successfully then it returns false. Use the ErrorInfo variable to view description of the error.
| Type | Description |
|---|---|
| bool |

SendmailSend(
$header, $body
)
:
boolSends mail using the $Sendmail program.
| Name | Type | Description |
|---|---|---|
| $header | ||
| $body |
| Type | Description |
|---|---|
| bool |
- Access
- public

ServerHostname(
)
:
stringReturns the server hostname or 'localhost.localdomain' if unknown.
| Type | Description |
|---|---|
| string |
- Access
- private

SetError(
$msg
)
:
voidAdds the error message to the error container.
Returns void.
| Name | Type | Description |
|---|---|---|
| $msg |
- Access
- private

SetLanguage(
string $lang_type
=
'en', string $lang_path
=
'language/'
)
:
boolSets the language for all class error messages. Returns false if it cannot load the language file. The default language type is English.
| Name | Type | Description |
|---|---|---|
| $lang_type | string | Type of language (e.g. Portuguese: "br") |
| $lang_path | string | Path to the language file directory |
| Type | Description |
|---|---|
| bool |
- Access
- public

Sign(
$cert_filename, string $key_filename, string $key_pass
)
:
voidSet the private key file and password to sign the message.
| Name | Type | Description |
|---|---|---|
| $cert_filename | ||
| $key_filename | string | Parameter File Name |
| $key_pass | string | Password for private key |
- Access
- public

SmtpConnect(
)
:
boolInitiates a connection to an SMTP server. Returns false if the operation failed.
| Type | Description |
|---|---|
| bool |
- Access
- public

SmtpSend(
$header, $body
)
:
boolSends mail via SMTP using PhpSMTP (Author: Chris Ryan). Returns bool. Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
| Name | Type | Description |
|---|---|---|
| $header | ||
| $body |
| Type | Description |
|---|---|
| bool |
- Access
- public

TextLine(
$value
)
:
stringReturns a formatted mail line.
| Name | Type | Description |
|---|---|---|
| $value |
| Type | Description |
|---|---|
| string |
- Access
- public

UTF8CharBoundary(
string $encodedText, int $maxLength
)
:
intFinds last character boundary prior to maxLength in a utf-8 quoted (printable) encoded string.
Original written by Colin Brown.
| Name | Type | Description |
|---|---|---|
| $encodedText | string | utf-8 QP text |
| $maxLength | int | find last character boundary prior to this length |
| Type | Description |
|---|---|
| int |
- Access
- public

WrapText(
$message, $length, $qp_mode
=
false
)
:
stringWraps message for use with mailers that do not automatically perform wrapping and for quoted-printable.
Original written by philippe.
| Name | Type | Description |
|---|---|---|
| $message | ||
| $length | ||
| $qp_mode |
| Type | Description |
|---|---|
| string |
- Access
- public

_mime_types(
$ext
=
''
)
:
\mimeGets the mime type of the embedded or inline image
| Name | Type | Description |
|---|---|---|
| $ext |
| Type | Description |
|---|---|
| \mime | type of ext |
- Access
- public

getFile(
string $filename
)
:
voidRead a file from a supplied filename and return it.
| Name | Type | Description |
|---|---|---|
| $filename | string | Parameter File Name |
- Access
- public

set(
string $name, mixed $value
=
''
)
:
voidSet (or reset) Class Objects (variables)
Usage Example: $page->set('X-Priority', '3');
| Name | Type | Description |
|---|---|---|
| $name | string | Parameter Name |
| $value | mixed | Parameter Value NOTE: will not work with arrays, there are no arrays to set/reset |
- Access
- public