Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
PHPMailer Class Reference

Public Member Functions

 __construct ($exceptions=false)
 IsHTML ($ishtml=true)
 IsSMTP ()
 IsMail ()
 IsSendmail ()
 IsQmail ()
 AddAddress ($address, $name= '')
 AddCC ($address, $name= '')
 AddBCC ($address, $name= '')
 AddReplyTo ($address, $name= '')
 SetFrom ($address, $name= '', $auto=1)
 Send ()
 SmtpConnect ()
 SmtpClose ()
 SetLanguage ($langcode= 'en', $lang_path= 'language/')
 GetTranslations ()
 AddrAppend ($type, $addr)
 AddrFormat ($addr)
 WrapText ($message, $length, $qp_mode=false)
 UTF8CharBoundary ($encodedText, $maxLength)
 SetWordWrap ()
 CreateHeader ()
 GetMailMIME ()
 CreateBody ()
 HeaderLine ($name, $value)
 TextLine ($value)
 AddAttachment ($path, $name= '', $encoding= 'base64', $type= 'application/octet-stream')
 GetAttachments ()
 EncodeString ($str, $encoding= 'base64')
 EncodeHeader ($str, $position= 'text')
 HasMultiBytes ($str)
 Base64EncodeWrapMB ($str)
 EncodeQPphp ($input= '', $line_max=76, $space_conv=false)
 EncodeQP ($string, $line_max=76, $space_conv=false)
 EncodeQ ($str, $position= 'text')
 AddStringAttachment ($string, $filename, $encoding= 'base64', $type= 'application/octet-stream')
 AddEmbeddedImage ($path, $cid, $name= '', $encoding= 'base64', $type= 'application/octet-stream')
 InlineImageExists ()
 ClearAddresses ()
 ClearCCs ()
 ClearBCCs ()
 ClearReplyTos ()
 ClearAllRecipients ()
 ClearAttachments ()
 ClearCustomHeaders ()
 IsError ()
 AddCustomHeader ($custom_header)
 MsgHTML ($message, $basedir= '')
 set ($name, $value= '')
 SecureHeader ($str)
 Sign ($cert_filename, $key_filename, $key_pass)
 DKIM_QP ($txt)
 DKIM_Sign ($s)
 DKIM_HeaderC ($s)
 DKIM_BodyC ($body)
 DKIM_Add ($headers_line, $subject, $body)
 __construct ($exceptions=false)
 IsHTML ($ishtml=true)
 IsSMTP ()
 IsMail ()
 IsSendmail ()
 IsQmail ()
 AddAddress ($address, $name= '')
 AddCC ($address, $name= '')
 AddBCC ($address, $name= '')
 AddReplyTo ($address, $name= '')
 SetFrom ($address, $name= '')
 Send ()
 SmtpConnect ()
 SmtpClose ()
 SetLanguage ($langcode= 'en', $lang_path= 'language/')
 GetTranslations ()
 AddrAppend ($type, $addr)
 AddrFormat ($addr)
 WrapText ($message, $length, $qp_mode=false)
 UTF8CharBoundary ($encodedText, $maxLength)
 SetWordWrap ()
 CreateHeader ()
 GetMailMIME ()
 CreateBody ()
 HeaderLine ($name, $value)
 TextLine ($value)
 AddAttachment ($path, $name= '', $encoding= 'base64', $type= 'application/octet-stream')
 GetAttachments ()
 EncodeString ($str, $encoding= 'base64')
 EncodeHeader ($str, $position= 'text')
 HasMultiBytes ($str)
 Base64EncodeWrapMB ($str)
 EncodeQPphp ($input= '', $line_max=76, $space_conv=false)
 EncodeQP ($string, $line_max=76, $space_conv=false)
 EncodeQ ($str, $position= 'text')
 AddStringAttachment ($string, $filename, $encoding= 'base64', $type= 'application/octet-stream')
 AddEmbeddedImage ($path, $cid, $name= '', $encoding= 'base64', $type= 'application/octet-stream')
 InlineImageExists ()
 ClearAddresses ()
 ClearCCs ()
 ClearBCCs ()
 ClearReplyTos ()
 ClearAllRecipients ()
 ClearAttachments ()
 ClearCustomHeaders ()
 IsError ()
 AddCustomHeader ($custom_header)
 MsgHTML ($message, $basedir= '')
 set ($name, $value= '')
 SecureHeader ($str)
 Sign ($cert_filename, $key_filename, $key_pass)

Static Public Member Functions

static ValidateAddress ($address)
static RFCDate ()
static _mime_types ($ext= '')
static ValidateAddress ($address)
static RFCDate ()
static _mime_types ($ext= '')

Public Attributes

 $Priority = 3
 $CharSet = 'iso-8859-1'
 $ContentType = 'text/plain'
 $Encoding = '8bit'
 $ErrorInfo = ''
 $From = 'root@localhost'
 $FromName = 'Root User'
 $Sender = ''
 $Subject = ''
 $Body = ''
 $AltBody = ''
 $WordWrap = 0
 $Mailer = 'mail'
 $Sendmail = '/usr/sbin/sendmail'
 $PluginDir = ''
 $ConfirmReadingTo = ''
 $Hostname = ''
 $MessageID = ''
 $Host = 'localhost'
 $Port = 25
 $Helo = ''
 $SMTPSecure = ''
 $SMTPAuth = false
 $Username = ''
 $Password = ''
 $Timeout = 10
 $SMTPDebug = false
 $SMTPKeepAlive = false
 $SingleTo = false
 $SingleToArray = array()
 $LE = "\n"
 $DKIM_selector = 'phpmailer'
 $DKIM_identity = ''
 $DKIM_domain = ''
 $DKIM_private = ''
 $action_function = ''
 $Version = '5.1'
const STOP_MESSAGE = 0
const STOP_CONTINUE = 1
const STOP_CRITICAL = 2
const VERSION = '5.0.0'

Protected Member Functions

 SendmailSend ($header, $body)
 MailSend ($header, $body)
 SmtpSend ($header, $body)
 SetError ($msg)
 doCallback ($isSent, $to, $cc, $bcc, $subject, $body)
 SendmailSend ($header, $body)
 MailSend ($header, $body)
 SmtpSend ($header, $body)
 SetError ($msg)

Protected Attributes

 $language = array()

Detailed Description

Definition at line 43 of file PHPMailer.php.

Constructor & Destructor Documentation

PHPMailer::__construct (   $exceptions = false)

Constructor

Parameters
boolean$exceptionsShould we throw external exceptions?

Definition at line 342 of file PHPMailer.php.

{
$this->exceptions = ($exceptions == true);
}
PHPMailer::__construct (   $exceptions = false)

Constructor

Parameters
boolean$exceptionsShould we throw external exceptions?

Definition at line 291 of file class.phpmailer.php.

{
$this->exceptions = ($exceptions == true);
}

Member Function Documentation

static PHPMailer::_mime_types (   $ext = '')
static

Gets the MIME type of the embedded or inline image

Parameters
stringFile extension public
Returns
string MIME type of ext

Definition at line 1915 of file class.phpmailer.php.

{
$mimes = array(
'hqx' => 'application/mac-binhex40',
'cpt' => 'application/mac-compactpro',
'doc' => 'application/msword',
'bin' => 'application/macbinary',
'dms' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'exe' => 'application/octet-stream',
'class' => 'application/octet-stream',
'psd' => 'application/octet-stream',
'so' => 'application/octet-stream',
'sea' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => 'application/pdf',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil',
'mif' => 'application/vnd.mif',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'wbxml' => 'application/vnd.wap.wbxml',
'wmlc' => 'application/vnd.wap.wmlc',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'dxr' => 'application/x-director',
'dvi' => 'application/x-dvi',
'gtar' => 'application/x-gtar',
'php' => 'application/x-httpd-php',
'php4' => 'application/x-httpd-php',
'php3' => 'application/x-httpd-php',
'phtml' => 'application/x-httpd-php',
'phps' => 'application/x-httpd-php-source',
'js' => 'application/x-javascript',
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'tar' => 'application/x-tar',
'tgz' => 'application/x-tar',
'xhtml' => 'application/xhtml+xml',
'xht' => 'application/xhtml+xml',
'zip' => 'application/zip',
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'mp3' => 'audio/mpeg',
'aif' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'ram' => 'audio/x-pn-realaudio',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'ra' => 'audio/x-realaudio',
'rv' => 'video/vnd.rn-realvideo',
'wav' => 'audio/x-wav',
'bmp' => 'image/bmp',
'gif' => 'image/gif',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'png' => 'image/png',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'css' => 'text/css',
'html' => 'text/html',
'htm' => 'text/html',
'shtml' => 'text/html',
'txt' => 'text/plain',
'text' => 'text/plain',
'log' => 'text/plain',
'rtx' => 'text/richtext',
'rtf' => 'text/rtf',
'xml' => 'text/xml',
'xsl' => 'text/xml',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'avi' => 'video/x-msvideo',
'movie' => 'video/x-sgi-movie',
'doc' => 'application/msword',
'word' => 'application/msword',
'xl' => 'application/excel',
'eml' => 'message/rfc822'
);
return (!isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
}
static PHPMailer::_mime_types (   $ext = '')
static

Gets the MIME type of the embedded or inline image

Parameters
stringFile extension public
Returns
string MIME type of ext

Definition at line 2041 of file PHPMailer.php.

Referenced by MsgHTML().

{
$mimes = array(
'hqx' => 'application/mac-binhex40',
'cpt' => 'application/mac-compactpro',
'doc' => 'application/msword',
'bin' => 'application/macbinary',
'dms' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'exe' => 'application/octet-stream',
'class' => 'application/octet-stream',
'psd' => 'application/octet-stream',
'so' => 'application/octet-stream',
'sea' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => 'application/pdf',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil',
'mif' => 'application/vnd.mif',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'wbxml' => 'application/vnd.wap.wbxml',
'wmlc' => 'application/vnd.wap.wmlc',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'dxr' => 'application/x-director',
'dvi' => 'application/x-dvi',
'gtar' => 'application/x-gtar',
'php' => 'application/x-httpd-php',
'php4' => 'application/x-httpd-php',
'php3' => 'application/x-httpd-php',
'phtml' => 'application/x-httpd-php',
'phps' => 'application/x-httpd-php-source',
'js' => 'application/x-javascript',
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'tar' => 'application/x-tar',
'tgz' => 'application/x-tar',
'xhtml' => 'application/xhtml+xml',
'xht' => 'application/xhtml+xml',
'zip' => 'application/zip',
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'mp3' => 'audio/mpeg',
'aif' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'ram' => 'audio/x-pn-realaudio',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'ra' => 'audio/x-realaudio',
'rv' => 'video/vnd.rn-realvideo',
'wav' => 'audio/x-wav',
'bmp' => 'image/bmp',
'gif' => 'image/gif',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'png' => 'image/png',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'css' => 'text/css',
'html' => 'text/html',
'htm' => 'text/html',
'shtml' => 'text/html',
'txt' => 'text/plain',
'text' => 'text/plain',
'log' => 'text/plain',
'rtx' => 'text/richtext',
'rtf' => 'text/rtf',
'xml' => 'text/xml',
'xsl' => 'text/xml',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'avi' => 'video/x-msvideo',
'movie' => 'video/x-sgi-movie',
'doc' => 'application/msword',
'word' => 'application/msword',
'xl' => 'application/excel',
'eml' => 'message/rfc822'
);
return (!isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
}
PHPMailer::AddAddress (   $address,
  $name = '' 
)

Adds a "To" address.

Parameters
string$address
string$name
Returns
boolean true on success, false if address already used

Definition at line 356 of file class.phpmailer.php.

{
return $this->AddAnAddress('to', $address, $name);
}
PHPMailer::AddAddress (   $address,
  $name = '' 
)

Adds a "To" address.

Parameters
string$address
string$name
Returns
boolean true on success, false if address already used

Definition at line 407 of file PHPMailer.php.

{
return $this->AddAnAddress('to', $address, $name);
}
PHPMailer::AddAttachment (   $path,
  $name = '',
  $encoding = 'base64',
  $type = 'application/octet-stream' 
)

Adds an attachment from a path on the filesystem. Returns false if the file could not be found or accessed.

Parameters
string$pathPath to the attachment.
string$nameOverrides the attachment name.
string$encodingFile encoding (see $Encoding).
string$typeFile extension (MIME) type.
Returns
bool

Definition at line 1218 of file class.phpmailer.php.

References SetError().

{
try {
if ( !@is_file($path) ) {
throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE);
}
$filename = basename($path);
if ( $name == '' ) {
$name = $filename;
}
$this->attachment[] = array(
0 => $path,
1 => $filename,
2 => $name,
3 => $encoding,
4 => $type,
5 => false, // isStringAttachment
6 => 'attachment',
7 => 0
);
} catch (phpmailerException $e) {
$this->SetError($e->getMessage());
if ($this->exceptions) {
throw $e;
}
echo $e->getMessage()."\n";
if ( $e->getCode() == self::STOP_CRITICAL ) {
return false;
}
}
return true;
}
PHPMailer::AddAttachment (   $path,
  $name = '',
  $encoding = 'base64',
  $type = 'application/octet-stream' 
)

Adds an attachment from a path on the filesystem. Returns false if the file could not be found or accessed.

Parameters
string$pathPath to the attachment.
string$nameOverrides the attachment name.
string$encodingFile encoding (see $Encoding).
string$typeFile extension (MIME) type.
Returns
bool

Definition at line 1344 of file PHPMailer.php.

References SetError().

{
try {
if ( !@is_file($path) ) {
throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE);
}
$filename = basename($path);
if ( $name == '' ) {
$name = $filename;
}
$this->attachment[] = array(
0 => $path,
1 => $filename,
2 => $name,
3 => $encoding,
4 => $type,
5 => false, // isStringAttachment
6 => 'attachment',
7 => 0
);
} catch (phpmailerException $e) {
$this->SetError($e->getMessage());
if ($this->exceptions) {
throw $e;
}
echo $e->getMessage()."\n";
if ( $e->getCode() == self::STOP_CRITICAL ) {
return false;
}
}
return true;
}
PHPMailer::AddBCC (   $address,
  $name = '' 
)

Adds a "Bcc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

Parameters
string$address
string$name
Returns
boolean true on success, false if address already used

Definition at line 378 of file class.phpmailer.php.

{
return $this->AddAnAddress('bcc', $address, $name);
}
PHPMailer::AddBCC (   $address,
  $name = '' 
)

Adds a "Bcc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

Parameters
string$address
string$name
Returns
boolean true on success, false if address already used

Definition at line 429 of file PHPMailer.php.

{
return $this->AddAnAddress('bcc', $address, $name);
}
PHPMailer::AddCC (   $address,
  $name = '' 
)

Adds a "Cc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

Parameters
string$address
string$name
Returns
boolean true on success, false if address already used

Definition at line 367 of file class.phpmailer.php.

{
return $this->AddAnAddress('cc', $address, $name);
}
PHPMailer::AddCC (   $address,
  $name = '' 
)

Adds a "Cc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

Parameters
string$address
string$name
Returns
boolean true on success, false if address already used

Definition at line 418 of file PHPMailer.php.

{
return $this->AddAnAddress('cc', $address, $name);
}
PHPMailer::AddCustomHeader (   $custom_header)

Adds a custom header. public

Returns
void

Definition at line 1868 of file class.phpmailer.php.

{
$this->CustomHeader[] = explode(':', $custom_header, 2);
}
PHPMailer::AddCustomHeader (   $custom_header)

Adds a custom header. public

Returns
void

Definition at line 1994 of file PHPMailer.php.

{
$this->CustomHeader[] = explode(':', $custom_header, 2);
}
PHPMailer::AddEmbeddedImage (   $path,
  $cid,
  $name = '',
  $encoding = 'base64',
  $type = 'application/octet-stream' 
)

Adds 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".

Parameters
string$pathPath to the attachment.
string$cidContent ID of the attachment. Use this to identify the Id for accessing the image in an HTML form.
string$nameOverrides the attachment name.
string$encodingFile encoding (see $Encoding).
string$typeFile extension (MIME) type.
Returns
bool

Definition at line 1657 of file class.phpmailer.php.

References SetError().

{
if ( !@is_file($path) ) {
$this->SetError($this->Lang('file_access') . $path);
return false;
}
$filename = basename($path);
if ( $name == '' ) {
$name = $filename;
}
// Append to $attachment array
$this->attachment[] = array(
0 => $path,
1 => $filename,
2 => $name,
3 => $encoding,
4 => $type,
5 => false, // isStringAttachment
6 => 'inline',
7 => $cid
);
return true;
}
PHPMailer::AddEmbeddedImage (   $path,
  $cid,
  $name = '',
  $encoding = 'base64',
  $type = 'application/octet-stream' 
)

Adds 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".

Parameters
string$pathPath to the attachment.
string$cidContent ID of the attachment. Use this to identify the Id for accessing the image in an HTML form.
string$nameOverrides the attachment name.
string$encodingFile encoding (see $Encoding).
string$typeFile extension (MIME) type.
Returns
bool

Definition at line 1783 of file PHPMailer.php.

References SetError().

Referenced by MsgHTML().

{
if ( !@is_file($path) ) {
$this->SetError($this->Lang('file_access') . $path);
return false;
}
$filename = basename($path);
if ( $name == '' ) {
$name = $filename;
}
// Append to $attachment array
$this->attachment[] = array(
0 => $path,
1 => $filename,
2 => $name,
3 => $encoding,
4 => $type,
5 => false, // isStringAttachment
6 => 'inline',
7 => $cid
);
return true;
}
PHPMailer::AddrAppend (   $type,
  $addr 
)

Creates recipient headers. public

Returns
string

Definition at line 777 of file class.phpmailer.php.

References AddrFormat().

{
$addr_str = $type . ': ';
$addresses = array();
foreach ($addr as $a) {
$addresses[] = $this->AddrFormat($a);
}
$addr_str .= implode(', ', $addresses);
$addr_str .= $this->LE;
return $addr_str;
}
PHPMailer::AddrAppend (   $type,
  $addr 
)

Creates recipient headers. public

Returns
string

Definition at line 897 of file PHPMailer.php.

References AddrFormat().

Referenced by CreateHeader().

{
$addr_str = $type . ': ';
$addresses = array();
foreach ($addr as $a) {
$addresses[] = $this->AddrFormat($a);
}
$addr_str .= implode(', ', $addresses);
$addr_str .= $this->LE;
return $addr_str;
}
PHPMailer::AddReplyTo (   $address,
  $name = '' 
)

Adds a "Reply-to" address.

Parameters
string$address
string$name
Returns
boolean

Definition at line 388 of file class.phpmailer.php.

{
return $this->AddAnAddress('ReplyTo', $address, $name);
}
PHPMailer::AddReplyTo (   $address,
  $name = '' 
)

Adds a "Reply-to" address.

Parameters
string$address
string$name
Returns
boolean

Definition at line 439 of file PHPMailer.php.

{
return $this->AddAnAddress('ReplyTo', $address, $name);
}
PHPMailer::AddrFormat (   $addr)

Formats an address correctly. public

Returns
string

Definition at line 794 of file class.phpmailer.php.

References EncodeHeader(), and SecureHeader().

{
if (empty($addr[1])) {
return $this->SecureHeader($addr[0]);
} else {
return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
}
}
PHPMailer::AddrFormat (   $addr)

Formats an address correctly. public

Returns
string

Definition at line 914 of file PHPMailer.php.

References EncodeHeader(), and SecureHeader().

Referenced by AddrAppend(), CreateHeader(), and MailSend().

{
if (empty($addr[1])) {
return $this->SecureHeader($addr[0]);
} else {
return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
}
}
PHPMailer::AddStringAttachment (   $string,
  $filename,
  $encoding = 'base64',
  $type = 'application/octet-stream' 
)

Adds 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.

Parameters
string$stringString attachment data.
string$filenameName of the attachment.
string$encodingFile encoding (see $Encoding).
string$typeFile extension (MIME) type.
Returns
void

Definition at line 1630 of file class.phpmailer.php.

{
// Append to $attachment array
$this->attachment[] = array(
0 => $string,
1 => $filename,
2 => $filename,
3 => $encoding,
4 => $type,
5 => true, // isStringAttachment
6 => 'attachment',
7 => 0
);
}
PHPMailer::AddStringAttachment (   $string,
  $filename,
  $encoding = 'base64',
  $type = 'application/octet-stream' 
)

Adds 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.

Parameters
string$stringString attachment data.
string$filenameName of the attachment.
string$encodingFile encoding (see $Encoding).
string$typeFile extension (MIME) type.
Returns
void

Definition at line 1756 of file PHPMailer.php.

{
// Append to $attachment array
$this->attachment[] = array(
0 => $string,
1 => $filename,
2 => basename($filename),
3 => $encoding,
4 => $type,
5 => true, // isStringAttachment
6 => 'attachment',
7 => 0
);
}
PHPMailer::Base64EncodeWrapMB (   $str)

Correctly 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 public

Parameters
string$strmulti-byte text to wrap encode
Returns
string

Definition at line 1473 of file class.phpmailer.php.

{
$start = "=?".$this->CharSet."?B?";
$end = "?=";
$encoded = "";
$mb_length = mb_strlen($str, $this->CharSet);
// Each line must have length <= 75, including $start and $end
$length = 75 - strlen($start) - strlen($end);
// Average multi-byte ratio
$ratio = $mb_length / strlen($str);
// Base64 has a 4:3 ratio
$offset = $avgLength = floor($length * $ratio * .75);
for ($i = 0; $i < $mb_length; $i += $offset) {
$lookBack = 0;
do {
$offset = $avgLength - $lookBack;
$chunk = mb_substr($str, $i, $offset, $this->CharSet);
$chunk = base64_encode($chunk);
$lookBack++;
}
while (strlen($chunk) > $length);
$encoded .= $chunk . $this->LE;
}
// Chomp the last linefeed
$encoded = substr($encoded, 0, -strlen($this->LE));
return $encoded;
}
PHPMailer::Base64EncodeWrapMB (   $str)

Correctly 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 public

Parameters
string$strmulti-byte text to wrap encode
Returns
string

Definition at line 1599 of file PHPMailer.php.

Referenced by EncodeHeader().

{
$start = "=?".$this->CharSet."?B?";
$end = "?=";
$encoded = "";
$mb_length = mb_strlen($str, $this->CharSet);
// Each line must have length <= 75, including $start and $end
$length = 75 - strlen($start) - strlen($end);
// Average multi-byte ratio
$ratio = $mb_length / strlen($str);
// Base64 has a 4:3 ratio
$offset = $avgLength = floor($length * $ratio * .75);
for ($i = 0; $i < $mb_length; $i += $offset) {
$lookBack = 0;
do {
$offset = $avgLength - $lookBack;
$chunk = mb_substr($str, $i, $offset, $this->CharSet);
$chunk = base64_encode($chunk);
$lookBack++;
}
while (strlen($chunk) > $length);
$encoded .= $chunk . $this->LE;
}
// Chomp the last linefeed
$encoded = substr($encoded, 0, -strlen($this->LE));
return $encoded;
}
PHPMailer::ClearAddresses ( )

Clears all recipients assigned in the TO array. Returns void.

Returns
void

Definition at line 1706 of file class.phpmailer.php.

{
foreach($this->to as $to) {
unset($this->all_recipients[strtolower($to[0])]);
}
$this->to = array();
}
PHPMailer::ClearAddresses ( )

Clears all recipients assigned in the TO array. Returns void.

Returns
void

Definition at line 1832 of file PHPMailer.php.

{
foreach($this->to as $to) {
unset($this->all_recipients[strtolower($to[0])]);
}
$this->to = array();
}
PHPMailer::ClearAllRecipients ( )

Clears all recipients assigned in the TO, CC and BCC array. Returns void.

Returns
void

Definition at line 1748 of file class.phpmailer.php.

{
$this->to = array();
$this->cc = array();
$this->bcc = array();
$this->all_recipients = array();
}
PHPMailer::ClearAllRecipients ( )

Clears all recipients assigned in the TO, CC and BCC array. Returns void.

Returns
void

Definition at line 1874 of file PHPMailer.php.

{
$this->to = array();
$this->cc = array();
$this->bcc = array();
$this->all_recipients = array();
}
PHPMailer::ClearAttachments ( )

Clears all previously set filesystem, string, and binary attachments. Returns void.

Returns
void

Definition at line 1760 of file class.phpmailer.php.

{
$this->attachment = array();
}
PHPMailer::ClearAttachments ( )

Clears all previously set filesystem, string, and binary attachments. Returns void.

Returns
void

Definition at line 1886 of file PHPMailer.php.

{
$this->attachment = array();
}
PHPMailer::ClearBCCs ( )

Clears all recipients assigned in the BCC array. Returns void.

Returns
void

Definition at line 1728 of file class.phpmailer.php.

{
foreach($this->bcc as $bcc) {
unset($this->all_recipients[strtolower($bcc[0])]);
}
$this->bcc = array();
}
PHPMailer::ClearBCCs ( )

Clears all recipients assigned in the BCC array. Returns void.

Returns
void

Definition at line 1854 of file PHPMailer.php.

{
foreach($this->bcc as $bcc) {
unset($this->all_recipients[strtolower($bcc[0])]);
}
$this->bcc = array();
}
PHPMailer::ClearCCs ( )

Clears all recipients assigned in the CC array. Returns void.

Returns
void

Definition at line 1717 of file class.phpmailer.php.

{
foreach($this->cc as $cc) {
unset($this->all_recipients[strtolower($cc[0])]);
}
$this->cc = array();
}
PHPMailer::ClearCCs ( )

Clears all recipients assigned in the CC array. Returns void.

Returns
void

Definition at line 1843 of file PHPMailer.php.

{
foreach($this->cc as $cc) {
unset($this->all_recipients[strtolower($cc[0])]);
}
$this->cc = array();
}
PHPMailer::ClearCustomHeaders ( )

Clears all custom headers. Returns void.

Returns
void

Definition at line 1768 of file class.phpmailer.php.

{
$this->CustomHeader = array();
}
PHPMailer::ClearCustomHeaders ( )

Clears all custom headers. Returns void.

Returns
void

Definition at line 1894 of file PHPMailer.php.

{
$this->CustomHeader = array();
}
PHPMailer::ClearReplyTos ( )

Clears all recipients assigned in the ReplyTo array. Returns void.

Returns
void

Definition at line 1739 of file class.phpmailer.php.

{
$this->ReplyTo = array();
}
PHPMailer::ClearReplyTos ( )

Clears all recipients assigned in the ReplyTo array. Returns void.

Returns
void

Definition at line 1865 of file PHPMailer.php.

{
$this->ReplyTo = array();
}
PHPMailer::CreateBody ( )

Assembles the message body. Returns an empty string on failure. public

Returns
string The assembled message body

Definition at line 1064 of file class.phpmailer.php.

References EncodeString(), GetMailMIME(), IsError(), and SetWordWrap().

{
$body = '';
if ($this->sign_key_file) {
$body .= $this->GetMailMIME();
}
$this->SetWordWrap();
switch($this->message_type) {
case 'alt':
$body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
$body .= $this->EncodeString($this->AltBody, $this->Encoding);
$body .= $this->LE.$this->LE;
$body .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
$body .= $this->EncodeString($this->Body, $this->Encoding);
$body .= $this->LE.$this->LE;
$body .= $this->EndBoundary($this->boundary[1]);
break;
case 'plain':
$body .= $this->EncodeString($this->Body, $this->Encoding);
break;
case 'attachments':
$body .= $this->GetBoundary($this->boundary[1], '', '', '');
$body .= $this->EncodeString($this->Body, $this->Encoding);
$body .= $this->LE;
$body .= $this->AttachAll();
break;
case 'alt_attachments':
$body .= sprintf("--%s%s", $this->boundary[1], $this->LE);
$body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
$body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
$body .= $this->EncodeString($this->AltBody, $this->Encoding);
$body .= $this->LE.$this->LE;
$body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
$body .= $this->EncodeString($this->Body, $this->Encoding);
$body .= $this->LE.$this->LE;
$body .= $this->EndBoundary($this->boundary[2]);
$body .= $this->AttachAll();
break;
}
if ($this->IsError()) {
$body = '';
} elseif ($this->sign_key_file) {
try {
$file = tempnam('', 'mail');
file_put_contents($file, $body); //TODO check this worked
$signed = tempnam("", "signed");
if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), NULL)) {
@unlink($file);
@unlink($signed);
$body = file_get_contents($signed);
} else {
@unlink($file);
@unlink($signed);
throw new phpmailerException($this->Lang("signing").openssl_error_string());
}
} catch (phpmailerException $e) {
$body = '';
if ($this->exceptions) {
throw $e;
}
}
}
return $body;
}
PHPMailer::CreateBody ( )

Assembles the message body. Returns an empty string on failure. public

Returns
string The assembled message body

Definition at line 1190 of file PHPMailer.php.

References EncodeString(), GetMailMIME(), IsError(), and SetWordWrap().

Referenced by Send().

{
$body = '';
if ($this->sign_key_file) {
$body .= $this->GetMailMIME();
}
$this->SetWordWrap();
switch($this->message_type) {
case 'alt':
$body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
$body .= $this->EncodeString($this->AltBody, $this->Encoding);
$body .= $this->LE.$this->LE;
$body .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
$body .= $this->EncodeString($this->Body, $this->Encoding);
$body .= $this->LE.$this->LE;
$body .= $this->EndBoundary($this->boundary[1]);
break;
case 'plain':
$body .= $this->EncodeString($this->Body, $this->Encoding);
break;
case 'attachments':
$body .= $this->GetBoundary($this->boundary[1], '', '', '');
$body .= $this->EncodeString($this->Body, $this->Encoding);
$body .= $this->LE;
$body .= $this->AttachAll();
break;
case 'alt_attachments':
$body .= sprintf("--%s%s", $this->boundary[1], $this->LE);
$body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
$body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
$body .= $this->EncodeString($this->AltBody, $this->Encoding);
$body .= $this->LE.$this->LE;
$body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
$body .= $this->EncodeString($this->Body, $this->Encoding);
$body .= $this->LE.$this->LE;
$body .= $this->EndBoundary($this->boundary[2]);
$body .= $this->AttachAll();
break;
}
if ($this->IsError()) {
$body = '';
} elseif ($this->sign_key_file) {
try {
$file = tempnam('', 'mail');
file_put_contents($file, $body); //TODO check this worked
$signed = tempnam("", "signed");
if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), NULL)) {
@unlink($file);
@unlink($signed);
$body = file_get_contents($signed);
} else {
@unlink($file);
@unlink($signed);
throw new phpmailerException($this->Lang("signing").openssl_error_string());
}
} catch (phpmailerException $e) {
$body = '';
if ($this->exceptions) {
throw $e;
}
}
}
return $body;
}
PHPMailer::CreateHeader ( )

Assembles message header. public

Returns
string The assembled header

Definition at line 953 of file class.phpmailer.php.

References AddrAppend(), EncodeHeader(), GetMailMIME(), HeaderLine(), and SecureHeader().

{
$result = '';
// Set the boundaries
$uniq_id = md5(uniqid(time()));
$this->boundary[1] = 'b1_' . $uniq_id;
$this->boundary[2] = 'b2_' . $uniq_id;
$result .= $this->HeaderLine('Date', self::RFCDate());
if($this->Sender == '') {
$result .= $this->HeaderLine('Return-Path', trim($this->From));
} else {
$result .= $this->HeaderLine('Return-Path', trim($this->Sender));
}
// To be created automatically by mail()
if($this->Mailer != 'mail') {
if(count($this->to) > 0) {
$result .= $this->AddrAppend('To', $this->to);
} elseif (count($this->cc) == 0) {
$result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
}
}
$from = array();
$from[0][0] = trim($this->From);
$from[0][1] = $this->FromName;
$result .= $this->AddrAppend('From', $from);
// sendmail and mail() extract Cc from the header before sending
if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) {
$result .= $this->AddrAppend('Cc', $this->cc);
}
// sendmail and mail() extract Bcc from the header before sending
if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
$result .= $this->AddrAppend('Bcc', $this->bcc);
}
if(count($this->ReplyTo) > 0) {
$result .= $this->AddrAppend('Reply-to', $this->ReplyTo);
}
// mail() sets the subject itself
if($this->Mailer != 'mail') {
$result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
}
if($this->MessageID != '') {
$result .= $this->HeaderLine('Message-ID',$this->MessageID);
} else {
$result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
}
$result .= $this->HeaderLine('X-Priority', $this->Priority);
$result .= $this->HeaderLine('X-Mailer', 'PHPMailer ' . self::VERSION . ' (phpmailer.codeworxtech.com)');
if($this->ConfirmReadingTo != '') {
$result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
}
// Add custom headers
for($index = 0; $index < count($this->CustomHeader); $index++) {
$result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
}
if (!$this->sign_key_file) {
$result .= $this->HeaderLine('MIME-Version', '1.0');
$result .= $this->GetMailMIME();
}
return $result;
}
PHPMailer::CreateHeader ( )

Assembles message header. public

Returns
string The assembled header

Definition at line 1073 of file PHPMailer.php.

References AddrAppend(), AddrFormat(), EncodeHeader(), GetMailMIME(), HeaderLine(), and SecureHeader().

Referenced by Send().

{
$result = '';
// Set the boundaries
$uniq_id = md5(uniqid(time()));
$this->boundary[1] = 'b1_' . $uniq_id;
$this->boundary[2] = 'b2_' . $uniq_id;
$result .= $this->HeaderLine('Date', self::RFCDate());
if($this->Sender == '') {
$result .= $this->HeaderLine('Return-Path', trim($this->From));
} else {
$result .= $this->HeaderLine('Return-Path', trim($this->Sender));
}
// To be created automatically by mail()
if($this->Mailer != 'mail') {
if ($this->SingleTo === true) {
foreach($this->to as $t) {
$this->SingleToArray[] = $this->AddrFormat($t);
}
} else {
if(count($this->to) > 0) {
$result .= $this->AddrAppend('To', $this->to);
} elseif (count($this->cc) == 0) {
$result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
}
}
}
$from = array();
$from[0][0] = trim($this->From);
$from[0][1] = $this->FromName;
$result .= $this->AddrAppend('From', $from);
// sendmail and mail() extract Cc from the header before sending
if(count($this->cc) > 0) {
$result .= $this->AddrAppend('Cc', $this->cc);
}
// sendmail and mail() extract Bcc from the header before sending
if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
$result .= $this->AddrAppend('Bcc', $this->bcc);
}
if(count($this->ReplyTo) > 0) {
$result .= $this->AddrAppend('Reply-to', $this->ReplyTo);
}
// mail() sets the subject itself
if($this->Mailer != 'mail') {
$result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
}
if($this->MessageID != '') {
$result .= $this->HeaderLine('Message-ID',$this->MessageID);
} else {
$result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
}
$result .= $this->HeaderLine('X-Priority', $this->Priority);
$result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (phpmailer.sourceforge.net)');
if($this->ConfirmReadingTo != '') {
$result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
}
// Add custom headers
for($index = 0; $index < count($this->CustomHeader); $index++) {
$result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
}
if (!$this->sign_key_file) {
$result .= $this->HeaderLine('MIME-Version', '1.0');
$result .= $this->GetMailMIME();
}
return $result;
}
PHPMailer::DKIM_Add (   $headers_line,
  $subject,
  $body 
)

Create the DKIM header, body, as new header

public

Parameters
string$headers_lineHeader lines
string$subjectSubject
string$bodyBody

Definition at line 2271 of file PHPMailer.php.

References DKIM_BodyC(), DKIM_HeaderC(), DKIM_QP(), and DKIM_Sign().

Referenced by Send().

{
$DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms
$DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
$DKIMquery = 'dns/txt'; // Query method
$DKIMtime = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
$subject_header = "Subject: $subject";
$headers = explode("\r\n",$headers_line);
foreach($headers as $header) {
if (strpos($header,'From:') === 0) {
$from_header=$header;
} elseif (strpos($header,'To:') === 0) {
$to_header=$header;
}
}
$from = str_replace('|','=7C',$this->DKIM_QP($from_header));
$to = str_replace('|','=7C',$this->DKIM_QP($to_header));
$subject = str_replace('|','=7C',$this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable
$body = $this->DKIM_BodyC($body);
$DKIMlen = strlen($body) ; // Length of body
$DKIMb64 = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body
$ident = ($this->DKIM_identity == '')? '' : " i=" . $this->DKIM_identity . ";";
$dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n".
"\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n".
"\th=From:To:Subject;\r\n".
"\td=" . $this->DKIM_domain . ";" . $ident . "\r\n".
"\tz=$from\r\n".
"\t|$to\r\n".
"\t|$subject;\r\n".
"\tbh=" . $DKIMb64 . ";\r\n".
"\tb=";
$toSign = $this->DKIM_HeaderC($from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs);
$signed = $this->DKIM_Sign($toSign);
return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n";
}
PHPMailer::DKIM_BodyC (   $body)

Generate DKIM Canonicalization Body

public

Parameters
string$bodyMessage Body

Definition at line 2251 of file PHPMailer.php.

Referenced by DKIM_Add().

{
if ($body == '') return "\r\n";
// stabilize line endings
$body=str_replace("\r\n","\n",$body);
$body=str_replace("\n","\r\n",$body);
// END stabilize line endings
while (substr($body,strlen($body)-4,4) == "\r\n\r\n") {
$body=substr($body,0,strlen($body)-2);
}
return $body;
}
PHPMailer::DKIM_HeaderC (   $s)

Generate DKIM Canonicalization Header

public

Parameters
string$sHeader

Definition at line 2232 of file PHPMailer.php.

Referenced by DKIM_Add().

{
$s=preg_replace("/\r\n\s+/"," ",$s);
$lines=explode("\r\n",$s);
foreach ($lines as $key=>$line) {
list($heading,$value)=explode(":",$line,2);
$heading=strtolower($heading);
$value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces
$lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value
}
$s=implode("\r\n",$lines);
return $s;
}
PHPMailer::DKIM_QP (   $txt)

Set the private key file and password to sign the message.

public

Parameters
string$key_filenameParameter File Name
string$key_passPassword for private key

Definition at line 2194 of file PHPMailer.php.

Referenced by DKIM_Add().

{
$tmp="";
$line="";
for ($i=0;$i<strlen($txt);$i++) {
$ord=ord($txt[$i]);
if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) {
$line.=$txt[$i];
} else {
$line.="=".sprintf("%02X",$ord);
}
}
return $line;
}
PHPMailer::DKIM_Sign (   $s)

Generate DKIM signature

public

Parameters
string$sHeader

Definition at line 2214 of file PHPMailer.php.

Referenced by DKIM_Add().

{
$privKeyStr = file_get_contents($this->DKIM_private);
if ($this->DKIM_passphrase!='') {
$privKey = openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase);
} else {
$privKey = $privKeyStr;
}
if (openssl_sign($s, $signature, $privKey)) {
return base64_encode($signature);
}
}
PHPMailer::EncodeHeader (   $str,
  $position = 'text' 
)

Encode a header string to best (shortest) of Q, B, quoted or none. public

Returns
string

Definition at line 1396 of file class.phpmailer.php.

References Base64EncodeWrapMB(), EncodeQ(), HasMultiBytes(), and WrapText().

{
$x = 0;
switch (strtolower($position)) {
case 'phrase':
if (!preg_match('/[\200-\377]/', $str)) {
// Can't use addslashes as we don't know what value has magic_quotes_sybase
$encoded = addcslashes($str, "\0..\37\177\\\"");
if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
return ($encoded);
} else {
return ("\"$encoded\"");
}
}
$x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
break;
case 'comment':
$x = preg_match_all('/[()"]/', $str, $matches);
// Fall-through
case 'text':
default:
$x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
break;
}
if ($x == 0) {
return ($str);
}
$maxlen = 75 - 7 - strlen($this->CharSet);
// Try to select the encoding which should produce the shortest output
if (strlen($str)/3 < $x) {
$encoding = 'B';
if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
// Use a custom function which correctly encodes and wraps long
// multibyte strings without breaking lines within a character
$encoded = $this->Base64EncodeWrapMB($str);
} else {
$encoded = base64_encode($str);
$maxlen -= $maxlen % 4;
$encoded = trim(chunk_split($encoded, $maxlen, "\n"));
}
} else {
$encoding = 'Q';
$encoded = $this->EncodeQ($str, $position);
$encoded = $this->WrapText($encoded, $maxlen, true);
$encoded = str_replace('='.$this->LE, "\n", trim($encoded));
}
$encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
$encoded = trim(str_replace("\n", $this->LE, $encoded));
return $encoded;
}
PHPMailer::EncodeHeader (   $str,
  $position = 'text' 
)

Encode a header string to best (shortest) of Q, B, quoted or none. public

Returns
string

Definition at line 1522 of file PHPMailer.php.

References Base64EncodeWrapMB(), EncodeQ(), HasMultiBytes(), and WrapText().

Referenced by AddrFormat(), CreateHeader(), and MailSend().

{
$x = 0;
switch (strtolower($position)) {
case 'phrase':
if (!preg_match('/[\200-\377]/', $str)) {
// Can't use addslashes as we don't know what value has magic_quotes_sybase
$encoded = addcslashes($str, "\0..\37\177\\\"");
if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
return ($encoded);
} else {
return ("\"$encoded\"");
}
}
$x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
break;
case 'comment':
$x = preg_match_all('/[()"]/', $str, $matches);
// Fall-through
case 'text':
default:
$x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
break;
}
if ($x == 0) {
return ($str);
}
$maxlen = 75 - 7 - strlen($this->CharSet);
// Try to select the encoding which should produce the shortest output
if (strlen($str)/3 < $x) {
$encoding = 'B';
if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
// Use a custom function which correctly encodes and wraps long
// multibyte strings without breaking lines within a character
$encoded = $this->Base64EncodeWrapMB($str);
} else {
$encoded = base64_encode($str);
$maxlen -= $maxlen % 4;
$encoded = trim(chunk_split($encoded, $maxlen, "\n"));
}
} else {
$encoding = 'Q';
$encoded = $this->EncodeQ($str, $position);
$encoded = $this->WrapText($encoded, $maxlen, true);
$encoded = str_replace('='.$this->LE, "\n", trim($encoded));
}
$encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
$encoded = trim(str_replace("\n", $this->LE, $encoded));
return $encoded;
}
PHPMailer::EncodeQ (   $str,
  $position = 'text' 
)

Encode string to q encoding. string $str the text to encode string $position Where the text is going to be used, see the RFC for what that means public string

Definition at line 1595 of file class.phpmailer.php.

{
// There should not be any EOL in the string
$encoded = preg_replace('/[\r\n]*/', '', $str);
switch (strtolower($position)) {
case 'phrase':
$encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
break;
case 'comment':
$encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
case 'text':
default:
// Replace every high ascii, control =, ? and _ characters
//TODO using /e (equivalent to eval()) is probably not a good idea
$encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
"'='.sprintf('%02X', ord('\\1'))", $encoded);
break;
}
// Replace every spaces to _ (more readable than =20)
$encoded = str_replace(' ', '_', $encoded);
return $encoded;
}
PHPMailer::EncodeQ (   $str,
  $position = 'text' 
)

Encode string to q encoding. string $str the text to encode string $position Where the text is going to be used, see the RFC for what that means public string

Definition at line 1721 of file PHPMailer.php.

Referenced by EncodeHeader().

{
// There should not be any EOL in the string
$encoded = preg_replace('/[\r\n]*/', '', $str);
switch (strtolower($position)) {
case 'phrase':
$encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
break;
case 'comment':
$encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
case 'text':
default:
// Replace every high ascii, control =, ? and _ characters
//TODO using /e (equivalent to eval()) is probably not a good idea
$encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
"'='.sprintf('%02X', ord('\\1'))", $encoded);
break;
}
// Replace every spaces to _ (more readable than =20)
$encoded = str_replace(' ', '_', $encoded);
return $encoded;
}
PHPMailer::EncodeQP (   $string,
  $line_max = 76,
  $space_conv = false 
)

Encode string to RFC2045 (6.7) quoted-printable format Uses a PHP5 stream filter to do the encoding about 64x faster than the old version Also results in same content as you started with after decoding

See Also
EncodeQPphp() public
Parameters
string$stringthe text to encode
integer$line_maxNumber of chars allowed on a line before wrapping
boolean$space_convDummy param for compatibility with existing EncodeQP function
Returns
string
Author
Marcus Bointon

Definition at line 1566 of file class.phpmailer.php.

References EncodeQPphp().

{
if (function_exists('quoted_printable_encode')) { //Use native function if it's available (>= PHP5.3)
return quoted_printable_encode($string);
}
$filters = stream_get_filters();
if (!in_array('convert.*', $filters)) { //Got convert stream filter?
return $this->EncodeQPphp($string, $line_max, $space_conv); //Fall back to old implementation
}
$fp = fopen('php://temp/', 'r+');
$string = preg_replace('/\r\n?/', $this->LE, $string); //Normalise line breaks
$params = array('line-length' => $line_max, 'line-break-chars' => $this->LE);
$s = stream_filter_append($fp, 'convert.quoted-printable-encode', STREAM_FILTER_READ, $params);
fputs($fp, $string);
rewind($fp);
$out = stream_get_contents($fp);
stream_filter_remove($s);
$out = preg_replace('/^\./m', '=2E', $out); //Encode . if it is first char on a line, workaround for bug in Exchange
fclose($fp);
return $out;
}
PHPMailer::EncodeQP (   $string,
  $line_max = 76,
  $space_conv = false 
)

Encode string to RFC2045 (6.7) quoted-printable format Uses a PHP5 stream filter to do the encoding about 64x faster than the old version Also results in same content as you started with after decoding

See Also
EncodeQPphp() public
Parameters
string$stringthe text to encode
integer$line_maxNumber of chars allowed on a line before wrapping
boolean$space_convDummy param for compatibility with existing EncodeQP function
Returns
string
Author
Marcus Bointon

Definition at line 1692 of file PHPMailer.php.

References EncodeQPphp().

Referenced by EncodeString().

{
if (function_exists('quoted_printable_encode')) { //Use native function if it's available (>= PHP5.3)
return quoted_printable_encode($string);
}
$filters = stream_get_filters();
if (!in_array('convert.*', $filters)) { //Got convert stream filter?
return $this->EncodeQPphp($string, $line_max, $space_conv); //Fall back to old implementation
}
$fp = fopen('php://temp/', 'r+');
$string = preg_replace('/\r\n?/', $this->LE, $string); //Normalise line breaks
$params = array('line-length' => $line_max, 'line-break-chars' => $this->LE);
$s = stream_filter_append($fp, 'convert.quoted-printable-encode', STREAM_FILTER_READ, $params);
fputs($fp, $string);
rewind($fp);
$out = stream_get_contents($fp);
stream_filter_remove($s);
$out = preg_replace('/^\./m', '=2E', $out); //Encode . if it is first char on a line, workaround for bug in Exchange
fclose($fp);
return $out;
}
PHPMailer::EncodeQPphp (   $input = '',
  $line_max = 76,
  $space_conv = false 
)

Encode string to quoted-printable. Only uses standard PHP, slow, but will always work public

Parameters
string$stringthe text to encode
integer$line_maxNumber of chars allowed on a line before wrapping
Returns
string

Definition at line 1513 of file class.phpmailer.php.

{
$hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
$lines = preg_split('/(?:\r\n|\r|\n)/', $input);
$eol = "\r\n";
$escape = '=';
$output = '';
while( list(, $line) = each($lines) ) {
$linlen = strlen($line);
$newline = '';
for($i = 0; $i < $linlen; $i++) {
$c = substr( $line, $i, 1 );
$dec = ord( $c );
if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
$c = '=2E';
}
if ( $dec == 32 ) {
if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
$c = '=20';
} else if ( $space_conv ) {
$c = '=20';
}
} elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
$h2 = floor($dec/16);
$h1 = floor($dec%16);
$c = $escape.$hex[$h2].$hex[$h1];
}
if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
$output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay
$newline = '';
// check if newline first character will be point or not
if ( $dec == 46 ) {
$c = '=2E';
}
}
$newline .= $c;
} // end of for
$output .= $newline.$eol;
} // end of while
return $output;
}
PHPMailer::EncodeQPphp (   $input = '',
  $line_max = 76,
  $space_conv = false 
)

Encode string to quoted-printable. Only uses standard PHP, slow, but will always work public

Parameters
string$stringthe text to encode
integer$line_maxNumber of chars allowed on a line before wrapping
Returns
string

Definition at line 1639 of file PHPMailer.php.

Referenced by EncodeQP().

{
$hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
$lines = preg_split('/(?:\r\n|\r|\n)/', $input);
$eol = "\r\n";
$escape = '=';
$output = '';
while( list(, $line) = each($lines) ) {
$linlen = strlen($line);
$newline = '';
for($i = 0; $i < $linlen; $i++) {
$c = substr( $line, $i, 1 );
$dec = ord( $c );
if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
$c = '=2E';
}
if ( $dec == 32 ) {
if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
$c = '=20';
} else if ( $space_conv ) {
$c = '=20';
}
} elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
$h2 = floor($dec/16);
$h1 = floor($dec%16);
$c = $escape.$hex[$h2].$hex[$h1];
}
if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
$output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay
$newline = '';
// check if newline first character will be point or not
if ( $dec == 46 ) {
$c = '=2E';
}
}
$newline .= $c;
} // end of for
$output .= $newline.$eol;
} // end of while
return $output;
}
PHPMailer::EncodeString (   $str,
  $encoding = 'base64' 
)

Encodes string to requested format. Returns an empty string on failure.

Parameters
string$strThe text to encode
string$encodingThe encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' public
Returns
string

Definition at line 1365 of file class.phpmailer.php.

References EncodeQP(), and SetError().

{
$encoded = '';
switch(strtolower($encoding)) {
case 'base64':
$encoded = chunk_split(base64_encode($str), 76, $this->LE);
break;
case '7bit':
case '8bit':
$encoded = $this->FixEOL($str);
//Make sure it ends with a line break
if (substr($encoded, -(strlen($this->LE))) != $this->LE)
$encoded .= $this->LE;
break;
case 'binary':
$encoded = $str;
break;
case 'quoted-printable':
$encoded = $this->EncodeQP($str);
break;
default:
$this->SetError($this->Lang('encoding') . $encoding);
break;
}
return $encoded;
}
PHPMailer::EncodeString (   $str,
  $encoding = 'base64' 
)

Encodes string to requested format. Returns an empty string on failure.

Parameters
string$strThe text to encode
string$encodingThe encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' public
Returns
string

Definition at line 1491 of file PHPMailer.php.

References EncodeQP(), and SetError().

Referenced by CreateBody().

{
$encoded = '';
switch(strtolower($encoding)) {
case 'base64':
$encoded = chunk_split(base64_encode($str), 76, $this->LE);
break;
case '7bit':
case '8bit':
$encoded = $this->FixEOL($str);
//Make sure it ends with a line break
if (substr($encoded, -(strlen($this->LE))) != $this->LE)
$encoded .= $this->LE;
break;
case 'binary':
$encoded = $str;
break;
case 'quoted-printable':
$encoded = $this->EncodeQP($str);
break;
default:
$this->SetError($this->Lang('encoding') . $encoding);
break;
}
return $encoded;
}
PHPMailer::GetAttachments ( )

Return the current array of attachments

Returns
array

Definition at line 1256 of file class.phpmailer.php.

{
return $this->attachment;
}
PHPMailer::GetAttachments ( )

Return the current array of attachments

Returns
array

Definition at line 1382 of file PHPMailer.php.

{
return $this->attachment;
}
PHPMailer::GetMailMIME ( )

Returns the message MIME. public

Returns
string

Definition at line 1030 of file class.phpmailer.php.

References HeaderLine(), InlineImageExists(), and TextLine().

{
$result = '';
switch($this->message_type) {
case 'plain':
$result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
$result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
break;
case 'attachments':
case 'alt_attachments':
if($this->InlineImageExists()){
$result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
} else {
$result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
$result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
}
break;
case 'alt':
$result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
$result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
break;
}
if($this->Mailer != 'mail') {
$result .= $this->LE.$this->LE;
}
return $result;
}
PHPMailer::GetMailMIME ( )

Returns the message MIME. public

Returns
string

Definition at line 1156 of file PHPMailer.php.

References HeaderLine(), InlineImageExists(), and TextLine().

Referenced by CreateBody(), and CreateHeader().

{
$result = '';
switch($this->message_type) {
case 'plain':
$result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
$result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
break;
case 'attachments':
case 'alt_attachments':
if($this->InlineImageExists()){
$result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
} else {
$result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
$result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
}
break;
case 'alt':
$result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
$result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
break;
}
if($this->Mailer != 'mail') {
$result .= $this->LE.$this->LE;
}
return $result;
}
PHPMailer::GetTranslations ( )

Return the current array of language strings

Returns
array

Definition at line 764 of file class.phpmailer.php.

{
return $this->language;
}
PHPMailer::GetTranslations ( )

Return the current array of language strings

Returns
array

Definition at line 884 of file PHPMailer.php.

{
return $this->language;
}
PHPMailer::HasMultiBytes (   $str)

Checks if a string contains multibyte characters. public

Parameters
string$strmulti-byte text to wrap encode
Returns
bool

Definition at line 1457 of file class.phpmailer.php.

{
if (function_exists('mb_strlen')) {
return (strlen($str) > mb_strlen($str, $this->CharSet));
} else { // Assume no multibytes (we can't handle without mbstring functions anyway)
return false;
}
}
PHPMailer::HasMultiBytes (   $str)

Checks if a string contains multibyte characters. public

Parameters
string$strmulti-byte text to wrap encode
Returns
bool

Definition at line 1583 of file PHPMailer.php.

Referenced by EncodeHeader().

{
if (function_exists('mb_strlen')) {
return (strlen($str) > mb_strlen($str, $this->CharSet));
} else { // Assume no multibytes (we can't handle without mbstring functions anyway)
return false;
}
}
PHPMailer::HeaderLine (   $name,
  $value 
)

Returns a formatted header line. public

Returns
string

Definition at line 1191 of file class.phpmailer.php.

{
return $name . ': ' . $value . $this->LE;
}
PHPMailer::HeaderLine (   $name,
  $value 
)

Returns a formatted header line. public

Returns
string

Definition at line 1317 of file PHPMailer.php.

Referenced by CreateHeader(), and GetMailMIME().

{
return $name . ': ' . $value . $this->LE;
}
PHPMailer::InlineImageExists ( )

Returns true if an inline attachment is present. public

Returns
bool

Definition at line 1689 of file class.phpmailer.php.

{
foreach($this->attachment as $attachment) {
if ($attachment[6] == 'inline') {
return true;
}
}
return false;
}
PHPMailer::InlineImageExists ( )

Returns true if an inline attachment is present. public

Returns
bool

Definition at line 1815 of file PHPMailer.php.

Referenced by GetMailMIME().

{
foreach($this->attachment as $attachment) {
if ($attachment[6] == 'inline') {
return true;
}
}
return false;
}
PHPMailer::IsError ( )

Returns true if an error occurred. public

Returns
bool

Definition at line 1847 of file class.phpmailer.php.

{
return ($this->error_count > 0);
}
PHPMailer::IsError ( )

Returns true if an error occurred. public

Returns
bool

Definition at line 1973 of file PHPMailer.php.

Referenced by CreateBody().

{
return ($this->error_count > 0);
}
PHPMailer::IsHTML (   $ishtml = true)

Sets message type to HTML.

Parameters
bool$ishtml
Returns
void

Definition at line 300 of file class.phpmailer.php.

{
if ($ishtml) {
$this->ContentType = 'text/html';
} else {
$this->ContentType = 'text/plain';
}
}
PHPMailer::IsHTML (   $ishtml = true)

Sets message type to HTML.

Parameters
bool$ishtml
Returns
void

Definition at line 351 of file PHPMailer.php.

Referenced by MsgHTML().

{
if ($ishtml) {
$this->ContentType = 'text/html';
} else {
$this->ContentType = 'text/plain';
}
}
PHPMailer::IsMail ( )

Sets Mailer to send message using PHP mail() function.

Returns
void

Definition at line 320 of file class.phpmailer.php.

{
$this->Mailer = 'mail';
}
PHPMailer::IsMail ( )

Sets Mailer to send message using PHP mail() function.

Returns
void

Definition at line 371 of file PHPMailer.php.

{
$this->Mailer = 'mail';
}
PHPMailer::IsQmail ( )

Sets Mailer to send message using the qmail MTA.

Returns
void

Definition at line 339 of file class.phpmailer.php.

{
if (stristr(ini_get('sendmail_path'), 'qmail')) {
$this->Sendmail = '/var/qmail/bin/sendmail';
}
$this->Mailer = 'sendmail';
}
PHPMailer::IsQmail ( )

Sets Mailer to send message using the qmail MTA.

Returns
void

Definition at line 390 of file PHPMailer.php.

{
if (stristr(ini_get('sendmail_path'), 'qmail')) {
$this->Sendmail = '/var/qmail/bin/sendmail';
}
$this->Mailer = 'sendmail';
}
PHPMailer::IsSendmail ( )

Sets Mailer to send message using the $Sendmail program.

Returns
void

Definition at line 328 of file class.phpmailer.php.

{
if (!stristr(ini_get('sendmail_path'), 'sendmail')) {
$this->Sendmail = '/var/qmail/bin/sendmail';
}
$this->Mailer = 'sendmail';
}
PHPMailer::IsSendmail ( )

Sets Mailer to send message using the $Sendmail program.

Returns
void

Definition at line 379 of file PHPMailer.php.

{
if (!stristr(ini_get('sendmail_path'), 'sendmail')) {
$this->Sendmail = '/var/qmail/bin/sendmail';
}
$this->Mailer = 'sendmail';
}
PHPMailer::IsSMTP ( )

Sets Mailer to send message using SMTP.

Returns
void

Definition at line 312 of file class.phpmailer.php.

{
$this->Mailer = 'smtp';
}
PHPMailer::IsSMTP ( )

Sets Mailer to send message using SMTP.

Returns
void

Definition at line 363 of file PHPMailer.php.

{
$this->Mailer = 'smtp';
}
PHPMailer::MailSend (   $header,
  $body 
)
protected

Sends mail using the PHP mail() function.

Parameters
string$headerThe message headers
string$bodyThe message body protected
Returns
bool

Definition at line 559 of file class.phpmailer.php.

References AddrFormat(), EncodeHeader(), and SecureHeader().

{
$toArr = array();
foreach($this->to as $t) {
$toArr[] = $this->AddrFormat($t);
}
$to = implode(', ', $toArr);
$params = sprintf("-oi -f %s", $this->Sender);
if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) {
$old_from = ini_get('sendmail_from');
ini_set('sendmail_from', $this->Sender);
if ($this->SingleTo === true && count($toArr) > 1) {
foreach ($toArr as $key => $val) {
$rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
}
} else {
$rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
}
} else {
if ($this->SingleTo === true && count($toArr) > 1) {
foreach ($toArr as $key => $val) {
$rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
}
} else {
$rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
}
}
if (isset($old_from)) {
ini_set('sendmail_from', $old_from);
}
if(!$rt) {
throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL);
}
return true;
}
PHPMailer::MailSend (   $header,
  $body 
)
protected

Sends mail using the PHP mail() function.

Parameters
string$headerThe message headers
string$bodyThe message body protected
Returns
bool

Definition at line 644 of file PHPMailer.php.

References AddrFormat(), EncodeHeader(), and SecureHeader().

Referenced by Send().

{
$toArr = array();
foreach($this->to as $t) {
$toArr[] = $this->AddrFormat($t);
}
$to = implode(', ', $toArr);
$params = sprintf("-oi -f %s", $this->Sender);
if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) {
$old_from = ini_get('sendmail_from');
ini_set('sendmail_from', $this->Sender);
if ($this->SingleTo === true && count($toArr) > 1) {
foreach ($toArr as $key => $val) {
$rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
// implement call back function if it exists
$isSent = ($rt == 1) ? 1 : 0;
$this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
}
} else {
$rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
// implement call back function if it exists
$isSent = ($rt == 1) ? 1 : 0;
$this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
}
} else {
if ($this->SingleTo === true && count($toArr) > 1) {
foreach ($toArr as $key => $val) {
$rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
// implement call back function if it exists
$isSent = ($rt == 1) ? 1 : 0;
$this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
}
} else {
$rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
// implement call back function if it exists
$isSent = ($rt == 1) ? 1 : 0;
$this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body);
}
}
if (isset($old_from)) {
ini_set('sendmail_from', $old_from);
}
if(!$rt) {
throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL);
}
return true;
}
PHPMailer::MsgHTML (   $message,
  $basedir = '' 
)

Evaluates the message and returns modifications for inline images and backgrounds public

Returns
$message

Definition at line 1877 of file class.phpmailer.php.

References _mime_types(), AddEmbeddedImage(), and IsHTML().

{
preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
if(isset($images[2])) {
foreach($images[2] as $i => $url) {
// do not change urls for absolute images (thanks to corvuscorax)
if (!preg_match('#^[A-z]+://#',$url)) {
$filename = basename($url);
$directory = dirname($url);
($directory == '.')?$directory='':'';
$cid = 'cid:' . md5($filename);
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$mimeType = self::_mime_types($ext);
if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
$message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
}
}
}
}
$this->IsHTML(true);
$this->Body = $message;
$textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
if (!empty($textMsg) && empty($this->AltBody)) {
$this->AltBody = html_entity_decode($textMsg);
}
if (empty($this->AltBody)) {
$this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n";
}
}
PHPMailer::MsgHTML (   $message,
  $basedir = '' 
)

Evaluates the message and returns modifications for inline images and backgrounds public

Returns
$message

Definition at line 2003 of file PHPMailer.php.

References _mime_types(), AddEmbeddedImage(), and IsHTML().

{
preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
if(isset($images[2])) {
foreach($images[2] as $i => $url) {
// do not change urls for absolute images (thanks to corvuscorax)
if (!preg_match('#^[A-z]+://#',$url)) {
$filename = basename($url);
$directory = dirname($url);
($directory == '.')?$directory='':'';
$cid = 'cid:' . md5($filename);
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$mimeType = self::_mime_types($ext);
if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
$message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
}
}
}
}
$this->IsHTML(true);
$this->Body = $message;
$textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
if (!empty($textMsg) && empty($this->AltBody)) {
$this->AltBody = html_entity_decode($textMsg);
}
if (empty($this->AltBody)) {
$this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n";
}
}
static PHPMailer::RFCDate ( )
static

Returns the proper RFC 822 formatted date. public

Returns
string

Definition at line 1798 of file class.phpmailer.php.

{
$tz = date('Z');
$tzs = ($tz < 0) ? '-' : '+';
$tz = abs($tz);
$tz = (int)($tz/3600)*100 + ($tz%3600)/60;
$result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
return $result;
}
static PHPMailer::RFCDate ( )
static

Returns the proper RFC 822 formatted date. public

Returns
string

Definition at line 1924 of file PHPMailer.php.

{
$tz = date('Z');
$tzs = ($tz < 0) ? '-' : '+';
$tz = abs($tz);
$tz = (int)($tz/3600)*100 + ($tz%3600)/60;
$result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
return $result;
}
PHPMailer::SecureHeader (   $str)

Strips newlines to prevent header injection. public

Parameters
string$strString
Returns
string

Definition at line 2042 of file class.phpmailer.php.

{
$str = str_replace("\r", '', $str);
$str = str_replace("\n", '', $str);
return trim($str);
}
PHPMailer::SecureHeader (   $str)

Strips newlines to prevent header injection. public

Parameters
string$strString
Returns
string

Definition at line 2168 of file PHPMailer.php.

Referenced by AddrFormat(), CreateHeader(), and MailSend().

{
$str = str_replace("\r", '', $str);
$str = str_replace("\n", '', $str);
return trim($str);
}
PHPMailer::Send ( )

Creates 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.

Returns
bool

Definition at line 486 of file class.phpmailer.php.

References CreateBody(), CreateHeader(), MailSend(), SendmailSend(), SetError(), and SmtpSend().

{
try {
if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL);
}
// Set whether the message is multipart/alternative
if(!empty($this->AltBody)) {
$this->ContentType = 'multipart/alternative';
}
$this->error_count = 0; // reset errors
$this->SetMessageType();
$header = $this->CreateHeader();
$body = $this->CreateBody();
if (empty($this->Body)) {
throw new phpmailerException($this->Lang('empty_message'), self::STOP_CRITICAL);
}
// Choose the mailer and send through it
switch($this->Mailer) {
case 'sendmail':
return $this->SendmailSend($header, $body);
case 'smtp':
return $this->SmtpSend($header, $body);
case 'mail':
default:
return $this->MailSend($header, $body);
}
} catch (phpmailerException $e) {
$this->SetError($e->getMessage());
if ($this->exceptions) {
throw $e;
}
echo $e->getMessage()."\n";
return false;
}
}
PHPMailer::Send ( )

Creates 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.

Returns
bool

Definition at line 545 of file PHPMailer.php.

References CreateBody(), CreateHeader(), DKIM_Add(), MailSend(), SendmailSend(), SetError(), and SmtpSend().

{
try {
if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL);
}
// Set whether the message is multipart/alternative
if(!empty($this->AltBody)) {
$this->ContentType = 'multipart/alternative';
}
$this->error_count = 0; // reset errors
$this->SetMessageType();
$header = $this->CreateHeader();
$body = $this->CreateBody();
if (empty($this->Body)) {
throw new phpmailerException($this->Lang('empty_message'), self::STOP_CRITICAL);
}
// digitally sign with DKIM if enabled
if ($this->DKIM_domain && $this->DKIM_private) {
$header_dkim = $this->DKIM_Add($header,$this->Subject,$body);
$header = str_replace("\r\n","\n",$header_dkim) . $header;
}
// Choose the mailer and send through it
switch($this->Mailer) {
case 'sendmail':
return $this->SendmailSend($header, $body);
case 'smtp':
return $this->SmtpSend($header, $body);
default:
return $this->MailSend($header, $body);
}
} catch (phpmailerException $e) {
$this->SetError($e->getMessage());
if ($this->exceptions) {
throw $e;
}
echo $e->getMessage()."\n";
return false;
}
}
PHPMailer::SendmailSend (   $header,
  $body 
)
protected

Sends mail using the $Sendmail program.

Parameters
string$headerThe message headers
string$bodyThe message body protected
Returns
bool

Definition at line 534 of file class.phpmailer.php.

{
if ($this->Sender != '') {
$sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
} else {
$sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
}
if(!@$mail = popen($sendmail, 'w')) {
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
fputs($mail, $header);
fputs($mail, $body);
$result = pclose($mail);
if($result != 0) {
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
return true;
}
PHPMailer::SendmailSend (   $header,
  $body 
)
protected

Sends mail using the $Sendmail program.

Parameters
string$headerThe message headers
string$bodyThe message body protected
Returns
bool

Definition at line 598 of file PHPMailer.php.

Referenced by Send().

{
if ($this->Sender != '') {
$sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
} else {
$sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
}
if ($this->SingleTo === true) {
foreach ($this->SingleToArray as $key => $val) {
if(!@$mail = popen($sendmail, 'w')) {
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
fputs($mail, "To: " . $val . "\n");
fputs($mail, $header);
fputs($mail, $body);
$result = pclose($mail);
// implement call back function if it exists
$isSent = ($result == 0) ? 1 : 0;
$this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
if($result != 0) {
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
}
} else {
if(!@$mail = popen($sendmail, 'w')) {
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
fputs($mail, $header);
fputs($mail, $body);
$result = pclose($mail);
// implement call back function if it exists
$isSent = ($result == 0) ? 1 : 0;
$this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body);
if($result != 0) {
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
}
return true;
}
PHPMailer::set (   $name,
  $value = '' 
)

Set (or reset) Class Objects (variables)

Usage Example: $page->set('X-Priority', '3');

public

Parameters
string$nameParameter Name
mixed$valueParameter Value NOTE: will not work with arrays, there are no arrays to set/reset
Todo:
Should this not be using __set() magic function?

Definition at line 2020 of file class.phpmailer.php.

References SetError().

{
try {
if (isset($this->$name) ) {
$this->$name = $value;
} else {
throw new phpmailerException($this->Lang('variable_set') . $name, self::STOP_CRITICAL);
}
} catch (Exception $e) {
$this->SetError($e->getMessage());
if ($e->getCode() == self::STOP_CRITICAL) {
return false;
}
}
return true;
}
PHPMailer::set (   $name,
  $value = '' 
)

Set (or reset) Class Objects (variables)

Usage Example: $page->set('X-Priority', '3');

public

Parameters
string$nameParameter Name
mixed$valueParameter Value NOTE: will not work with arrays, there are no arrays to set/reset
Todo:
Should this not be using __set() magic function?

Definition at line 2146 of file PHPMailer.php.

References SetError().

{
try {
if (isset($this->$name) ) {
$this->$name = $value;
} else {
throw new phpmailerException($this->Lang('variable_set') . $name, self::STOP_CRITICAL);
}
} catch (Exception $e) {
$this->SetError($e->getMessage());
if ($e->getCode() == self::STOP_CRITICAL) {
return false;
}
}
return true;
}
PHPMailer::SetError (   $msg)
protected

Adds the error message to the error container. protected

Returns
void

Definition at line 1781 of file class.phpmailer.php.

{
$this->error_count++;
if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
$lasterror = $this->smtp->getError();
if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
$msg .= '<p>' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n";
}
}
$this->ErrorInfo = $msg;
}
PHPMailer::SetError (   $msg)
protected

Adds the error message to the error container. protected

Returns
void

Definition at line 1907 of file PHPMailer.php.

Referenced by AddAttachment(), AddEmbeddedImage(), EncodeString(), Send(), set(), and SetFrom().

{
$this->error_count++;
if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
$lasterror = $this->smtp->getError();
if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
$msg .= '<p>' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n";
}
}
$this->ErrorInfo = $msg;
}
PHPMailer::SetFrom (   $address,
  $name = '' 
)

Set the From and FromName properties

Parameters
string$address
string$name
Returns
boolean

Definition at line 437 of file class.phpmailer.php.

References SetError().

{
$address = trim($address);
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
if (!self::ValidateAddress($address)) {
$this->SetError($this->Lang('invalid_address').': '. $address);
if ($this->exceptions) {
throw new phpmailerException($this->Lang('invalid_address').': '.$address);
}
echo $this->Lang('invalid_address').': '.$address;
return false;
}
$this->From = $address;
$this->FromName = $name;
return true;
}
PHPMailer::SetFrom (   $address,
  $name = '',
  $auto = 1 
)

Set the From and FromName properties

Parameters
string$address
string$name
Returns
boolean

Definition at line 488 of file PHPMailer.php.

References SetError().

{
$address = trim($address);
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
if (!self::ValidateAddress($address)) {
$this->SetError($this->Lang('invalid_address').': '. $address);
if ($this->exceptions) {
throw new phpmailerException($this->Lang('invalid_address').': '.$address);
}
echo $this->Lang('invalid_address').': '.$address;
return false;
}
$this->From = $address;
$this->FromName = $name;
if ($auto) {
if (empty($this->ReplyTo)) {
$this->AddAnAddress('ReplyTo', $address, $name);
}
if (empty($this->Sender)) {
$this->Sender = $address;
}
}
return true;
}
PHPMailer::SetLanguage (   $langcode = 'en',
  $lang_path = 'language/' 
)

Sets the language for all class error messages. Returns false if it cannot load the language file. The default language is English.

Parameters
string$langcodeISO 639-1 2-character language code (e.g. Portuguese: "br")
string$lang_pathPath to the language file directory public

Definition at line 730 of file class.phpmailer.php.

{
//Define full set of translatable strings
$PHPMAILER_LANG = array(
'provide_address' => 'You must provide at least one recipient email address.',
'mailer_not_supported' => ' mailer is not supported.',
'execute' => 'Could not execute: ',
'instantiate' => 'Could not instantiate mail function.',
'authenticate' => 'SMTP Error: Could not authenticate.',
'from_failed' => 'The following From address failed: ',
'recipients_failed' => 'SMTP Error: The following recipients failed: ',
'data_not_accepted' => 'SMTP Error: Data not accepted.',
'connect_host' => 'SMTP Error: Could not connect to SMTP host.',
'file_access' => 'Could not access file: ',
'file_open' => 'File Error: Could not open file: ',
'encoding' => 'Unknown encoding: ',
'signing' => 'Signing Error: ',
'smtp_error' => 'SMTP server error: ',
'empty_message' => 'Message body empty',
'invalid_address' => 'Invalid address',
'variable_set' => 'Cannot set or reset variable: '
);
//Overwrite language-specific strings. This way we'll never have missing translations - no more "language string failed to load"!
$l = true;
if ($langcode != 'en') { //There is no English translation file
$l = @include $lang_path.'phpmailer.lang-'.$langcode.'.php';
}
$this->language = $PHPMAILER_LANG;
return ($l == true); //Returns false if language not found
}
PHPMailer::SetLanguage (   $langcode = 'en',
  $lang_path = 'language/' 
)

Sets the language for all class error messages. Returns false if it cannot load the language file. The default language is English.

Parameters
string$langcodeISO 639-1 2-character language code (e.g. Portuguese: "br")
string$lang_pathPath to the language file directory public

Definition at line 850 of file PHPMailer.php.

{
//Define full set of translatable strings
$PHPMAILER_LANG = array(
'provide_address' => 'You must provide at least one recipient email address.',
'mailer_not_supported' => ' mailer is not supported.',
'execute' => 'Could not execute: ',
'instantiate' => 'Could not instantiate mail function.',
'authenticate' => 'SMTP Error: Could not authenticate.',
'from_failed' => 'The following From address failed: ',
'recipients_failed' => 'SMTP Error: The following recipients failed: ',
'data_not_accepted' => 'SMTP Error: Data not accepted.',
'connect_host' => 'SMTP Error: Could not connect to SMTP host.',
'file_access' => 'Could not access file: ',
'file_open' => 'File Error: Could not open file: ',
'encoding' => 'Unknown encoding: ',
'signing' => 'Signing Error: ',
'smtp_error' => 'SMTP server error: ',
'empty_message' => 'Message body empty',
'invalid_address' => 'Invalid address',
'variable_set' => 'Cannot set or reset variable: '
);
//Overwrite language-specific strings. This way we'll never have missing translations - no more "language string failed to load"!
$l = true;
if ($langcode != 'en') { //There is no English translation file
$l = @include $lang_path.'phpmailer.lang-'.$langcode.'.php';
}
$this->language = $PHPMAILER_LANG;
return ($l == true); //Returns false if language not found
}
PHPMailer::SetWordWrap ( )

Set the body wrapping. public

Returns
void

Definition at line 932 of file class.phpmailer.php.

References WrapText().

{
if($this->WordWrap < 1) {
return;
}
switch($this->message_type) {
case 'alt':
case 'alt_attachments':
$this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
break;
default:
$this->Body = $this->WrapText($this->Body, $this->WordWrap);
break;
}
}
PHPMailer::SetWordWrap ( )

Set the body wrapping. public

Returns
void

Definition at line 1052 of file PHPMailer.php.

References WrapText().

Referenced by CreateBody().

{
if($this->WordWrap < 1) {
return;
}
switch($this->message_type) {
case 'alt':
case 'alt_attachments':
$this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
break;
default:
$this->Body = $this->WrapText($this->Body, $this->WordWrap);
break;
}
}
PHPMailer::Sign (   $cert_filename,
  $key_filename,
  $key_pass 
)

Set the private key file and password to sign the message.

public

Parameters
string$key_filenameParameter File Name
string$key_passPassword for private key

Definition at line 2055 of file class.phpmailer.php.

{
$this->sign_cert_file = $cert_filename;
$this->sign_key_file = $key_filename;
$this->sign_key_pass = $key_pass;
}
PHPMailer::Sign (   $cert_filename,
  $key_filename,
  $key_pass 
)

Set the private key file and password to sign the message.

public

Parameters
string$key_filenameParameter File Name
string$key_passPassword for private key

Definition at line 2181 of file PHPMailer.php.

{
$this->sign_cert_file = $cert_filename;
$this->sign_key_file = $key_filename;
$this->sign_key_pass = $key_pass;
}
PHPMailer::SmtpClose ( )

Closes the active SMTP session if one exists.

Returns
void

Definition at line 714 of file class.phpmailer.php.

{
if(!is_null($this->smtp)) {
if($this->smtp->Connected()) {
$this->smtp->Quit();
$this->smtp->Close();
}
}
}
PHPMailer::SmtpClose ( )

Closes the active SMTP session if one exists.

Returns
void

Definition at line 834 of file PHPMailer.php.

{
if(!is_null($this->smtp)) {
if($this->smtp->Connected()) {
$this->smtp->Quit();
$this->smtp->Close();
}
}
}
PHPMailer::SmtpConnect ( )

Initiates a connection to an SMTP server. Returns false if the operation failed. SMTP public

Returns
bool

Definition at line 652 of file class.phpmailer.php.

{
if(is_null($this->smtp)) {
$this->smtp = new SMTP();
}
$this->smtp->do_debug = $this->SMTPDebug;
$hosts = explode(';', $this->Host);
$index = 0;
$connection = $this->smtp->Connected();
// Retry while there is no connection
try {
while($index < count($hosts) && !$connection) {
$hostinfo = array();
if (preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) {
$host = $hostinfo[1];
$port = $hostinfo[2];
} else {
$host = $hosts[$index];
$port = $this->Port;
}
$tls = ($this->SMTPSecure == 'tls');
$ssl = ($this->SMTPSecure == 'ssl');
if ($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) {
$hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname());
$this->smtp->Hello($hello);
if ($tls) {
if (!$this->smtp->StartTLS()) {
throw new phpmailerException($this->Lang('tls'));
}
//We must resend HELO after tls negotiation
$this->smtp->Hello($hello);
}
$connection = true;
if ($this->SMTPAuth) {
if (!$this->smtp->Authenticate($this->Username, $this->Password)) {
throw new phpmailerException($this->Lang('authenticate'));
}
}
}
$index++;
if (!$connection) {
throw new phpmailerException($this->Lang('connect_host'));
}
}
} catch (phpmailerException $e) {
$this->smtp->Reset();
throw $e;
}
return true;
}
PHPMailer::SmtpConnect ( )

Initiates a connection to an SMTP server. Returns false if the operation failed. SMTP public

Returns
bool

Definition at line 772 of file PHPMailer.php.

Referenced by SmtpSend().

{
if(is_null($this->smtp)) {
$this->smtp = new SMTP();
}
$this->smtp->do_debug = $this->SMTPDebug;
$hosts = explode(';', $this->Host);
$index = 0;
$connection = $this->smtp->Connected();
// Retry while there is no connection
try {
while($index < count($hosts) && !$connection) {
$hostinfo = array();
if (preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) {
$host = $hostinfo[1];
$port = $hostinfo[2];
} else {
$host = $hosts[$index];
$port = $this->Port;
}
$tls = ($this->SMTPSecure == 'tls');
$ssl = ($this->SMTPSecure == 'ssl');
if ($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) {
$hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname());
$this->smtp->Hello($hello);
if ($tls) {
if (!$this->smtp->StartTLS()) {
throw new phpmailerException($this->Lang('tls'));
}
//We must resend HELO after tls negotiation
$this->smtp->Hello($hello);
}
$connection = true;
if ($this->SMTPAuth) {
if (!$this->smtp->Authenticate($this->Username, $this->Password)) {
throw new phpmailerException($this->Lang('authenticate'));
}
}
}
$index++;
if (!$connection) {
throw new phpmailerException($this->Lang('connect_host'));
}
}
} catch (phpmailerException $e) {
$this->smtp->Reset();
throw $e;
}
return true;
}
PHPMailer::SmtpSend (   $header,
  $body 
)
protected

Sends mail via SMTP using PhpSMTP Returns false if there is a bad MAIL FROM, RCPT, or DATA input.

Parameters
string$headerThe message headers
string$bodyThe message body SMTP protected
Returns
bool

Definition at line 604 of file class.phpmailer.php.

References SmtpConnect().

{
require_once $this->PluginDir . 'class.smtp.php';
$bad_rcpt = array();
if(!$this->SmtpConnect()) {
throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
}
$smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
if(!$this->smtp->Mail($smtp_from)) {
throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
}
// Attempt to send attach all recipients
foreach($this->to as $to) {
if (!$this->smtp->Recipient($to[0])) {
$bad_rcpt[] = $to[0];
}
}
foreach($this->cc as $cc) {
if (!$this->smtp->Recipient($cc[0])) {
$bad_rcpt[] = $cc[0];
}
}
foreach($this->bcc as $bcc) {
if (!$this->smtp->Recipient($bcc[0])) {
$bad_rcpt[] = $bcc[0];
}
}
if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses
$badaddresses = implode(', ', $bad_rcpt);
throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
}
if(!$this->smtp->Data($header . $body)) {
throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL);
}
if($this->SMTPKeepAlive == true) {
$this->smtp->Reset();
}
return true;
}
PHPMailer::SmtpSend (   $header,
  $body 
)
protected

Sends mail via SMTP using PhpSMTP Returns false if there is a bad MAIL FROM, RCPT, or DATA input.

Parameters
string$headerThe message headers
string$bodyThe message body SMTP protected
Returns
bool

Definition at line 701 of file PHPMailer.php.

References SmtpConnect().

Referenced by Send().

{
require_once $this->PluginDir . 'class.smtp.php';
$bad_rcpt = array();
if(!$this->SmtpConnect()) {
throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
}
$smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
if(!$this->smtp->Mail($smtp_from)) {
throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
}
// Attempt to send attach all recipients
foreach($this->to as $to) {
if (!$this->smtp->Recipient($to[0])) {
$bad_rcpt[] = $to[0];
// implement call back function if it exists
$isSent = 0;
$this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
} else {
// implement call back function if it exists
$isSent = 1;
$this->doCallback($isSent,$to[0],'','',$this->Subject,$body);
}
}
foreach($this->cc as $cc) {
if (!$this->smtp->Recipient($cc[0])) {
$bad_rcpt[] = $cc[0];
// implement call back function if it exists
$isSent = 0;
$this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
} else {
// implement call back function if it exists
$isSent = 1;
$this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body);
}
}
foreach($this->bcc as $bcc) {
if (!$this->smtp->Recipient($bcc[0])) {
$bad_rcpt[] = $bcc[0];
// implement call back function if it exists
$isSent = 0;
$this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
} else {
// implement call back function if it exists
$isSent = 1;
$this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body);
}
}
if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses
$badaddresses = implode(', ', $bad_rcpt);
throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses);
}
if(!$this->smtp->Data($header . $body)) {
throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL);
}
if($this->SMTPKeepAlive == true) {
$this->smtp->Reset();
}
return true;
}
PHPMailer::TextLine (   $value)

Returns a formatted mail line. public

Returns
string

Definition at line 1200 of file class.phpmailer.php.

{
return $value . $this->LE;
}
PHPMailer::TextLine (   $value)

Returns a formatted mail line. public

Returns
string

Definition at line 1326 of file PHPMailer.php.

Referenced by GetMailMIME().

{
return $value . $this->LE;
}
PHPMailer::UTF8CharBoundary (   $encodedText,
  $maxLength 
)

Finds last character boundary prior to maxLength in a utf-8 quoted (printable) encoded string. Original written by Colin Brown. public

Parameters
string$encodedTextutf-8 QP text
int$maxLengthfind last character boundary prior to this length
Returns
int

Definition at line 894 of file class.phpmailer.php.

{
$foundSplitPos = false;
$lookBack = 3;
while (!$foundSplitPos) {
$lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
$encodedCharPos = strpos($lastChunk, "=");
if ($encodedCharPos !== false) {
// Found start of encoded character byte within $lookBack block.
// Check the encoded byte value (the 2 chars after the '=')
$hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
$dec = hexdec($hex);
if ($dec < 128) { // Single byte character.
// If the encoded char was found at pos 0, it will fit
// otherwise reduce maxLength to start of the encoded char
$maxLength = ($encodedCharPos == 0) ? $maxLength :
$maxLength - ($lookBack - $encodedCharPos);
$foundSplitPos = true;
} elseif ($dec >= 192) { // First byte of a multi byte character
// Reduce maxLength to split at start of character
$maxLength = $maxLength - ($lookBack - $encodedCharPos);
$foundSplitPos = true;
} elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
$lookBack += 3;
}
} else {
// No encoded character found
$foundSplitPos = true;
}
}
return $maxLength;
}
PHPMailer::UTF8CharBoundary (   $encodedText,
  $maxLength 
)

Finds last character boundary prior to maxLength in a utf-8 quoted (printable) encoded string. Original written by Colin Brown. public

Parameters
string$encodedTextutf-8 QP text
int$maxLengthfind last character boundary prior to this length
Returns
int

Definition at line 1014 of file PHPMailer.php.

Referenced by WrapText().

{
$foundSplitPos = false;
$lookBack = 3;
while (!$foundSplitPos) {
$lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
$encodedCharPos = strpos($lastChunk, "=");
if ($encodedCharPos !== false) {
// Found start of encoded character byte within $lookBack block.
// Check the encoded byte value (the 2 chars after the '=')
$hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
$dec = hexdec($hex);
if ($dec < 128) { // Single byte character.
// If the encoded char was found at pos 0, it will fit
// otherwise reduce maxLength to start of the encoded char
$maxLength = ($encodedCharPos == 0) ? $maxLength :
$maxLength - ($lookBack - $encodedCharPos);
$foundSplitPos = true;
} elseif ($dec >= 192) { // First byte of a multi byte character
// Reduce maxLength to split at start of character
$maxLength = $maxLength - ($lookBack - $encodedCharPos);
$foundSplitPos = true;
} elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
$lookBack += 3;
}
} else {
// No encoded character found
$foundSplitPos = true;
}
}
return $maxLength;
}
static PHPMailer::ValidateAddress (   $address)
static

Check that a string looks roughly like an email address should Static so it can be used without instantiation Tries to use PHP built-in validator in the filter extension (from PHP 5.2), falls back to a reasonably competent regex validator Conforms approximately to RFC2822 Original pattern found here string $address The email address to check boolean public

Definition at line 464 of file class.phpmailer.php.

{
if (function_exists('filter_var')) { //Introduced in PHP 5.2
if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
return false;
} else {
return true;
}
} else {
return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
}
}
static PHPMailer::ValidateAddress (   $address)
static

Check that a string looks roughly like an email address should Static so it can be used without instantiation Tries to use PHP built-in validator in the filter extension (from PHP 5.2), falls back to a reasonably competent regex validator Conforms approximately to RFC2822 Original pattern found here string $address The email address to check boolean public

Definition at line 523 of file PHPMailer.php.

{
if (function_exists('filter_var')) { //Introduced in PHP 5.2
if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
return false;
} else {
return true;
}
} else {
return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
}
}
PHPMailer::WrapText (   $message,
  $length,
  $qp_mode = false 
)

Wraps message for use with mailers that do not automatically perform wrapping and for quoted-printable. Original written by philippe.

Parameters
string$messageThe message to wrap
integer$lengthThe line length to wrap to
boolean$qp_modeWhether to run in Quoted-Printable mode public
Returns
string

Definition at line 812 of file class.phpmailer.php.

References UTF8CharBoundary().

{
$soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
// If utf-8 encoding is used, we will need to make sure we don't
// split multibyte characters when we wrap
$is_utf8 = (strtolower($this->CharSet) == "utf-8");
$message = $this->FixEOL($message);
if (substr($message, -1) == $this->LE) {
$message = substr($message, 0, -1);
}
$line = explode($this->LE, $message);
$message = '';
for ($i=0 ;$i < count($line); $i++) {
$line_part = explode(' ', $line[$i]);
$buf = '';
for ($e = 0; $e<count($line_part); $e++) {
$word = $line_part[$e];
if ($qp_mode and (strlen($word) > $length)) {
$space_left = $length - strlen($buf) - 1;
if ($e != 0) {
if ($space_left > 20) {
$len = $space_left;
if ($is_utf8) {
$len = $this->UTF8CharBoundary($word, $len);
} elseif (substr($word, $len - 1, 1) == "=") {
$len--;
} elseif (substr($word, $len - 2, 1) == "=") {
$len -= 2;
}
$part = substr($word, 0, $len);
$word = substr($word, $len);
$buf .= ' ' . $part;
$message .= $buf . sprintf("=%s", $this->LE);
} else {
$message .= $buf . $soft_break;
}
$buf = '';
}
while (strlen($word) > 0) {
$len = $length;
if ($is_utf8) {
$len = $this->UTF8CharBoundary($word, $len);
} elseif (substr($word, $len - 1, 1) == "=") {
$len--;
} elseif (substr($word, $len - 2, 1) == "=") {
$len -= 2;
}
$part = substr($word, 0, $len);
$word = substr($word, $len);
if (strlen($word) > 0) {
$message .= $part . sprintf("=%s", $this->LE);
} else {
$buf = $part;
}
}
} else {
$buf_o = $buf;
$buf .= ($e == 0) ? $word : (' ' . $word);
if (strlen($buf) > $length and $buf_o != '') {
$message .= $buf_o . $soft_break;
$buf = $word;
}
}
}
$message .= $buf . $this->LE;
}
return $message;
}
PHPMailer::WrapText (   $message,
  $length,
  $qp_mode = false 
)

Wraps message for use with mailers that do not automatically perform wrapping and for quoted-printable. Original written by philippe.

Parameters
string$messageThe message to wrap
integer$lengthThe line length to wrap to
boolean$qp_modeWhether to run in Quoted-Printable mode public
Returns
string

Definition at line 932 of file PHPMailer.php.

References UTF8CharBoundary().

Referenced by EncodeHeader(), and SetWordWrap().

{
$soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
// If utf-8 encoding is used, we will need to make sure we don't
// split multibyte characters when we wrap
$is_utf8 = (strtolower($this->CharSet) == "utf-8");
$message = $this->FixEOL($message);
if (substr($message, -1) == $this->LE) {
$message = substr($message, 0, -1);
}
$line = explode($this->LE, $message);
$message = '';
for ($i=0 ;$i < count($line); $i++) {
$line_part = explode(' ', $line[$i]);
$buf = '';
for ($e = 0; $e<count($line_part); $e++) {
$word = $line_part[$e];
if ($qp_mode and (strlen($word) > $length)) {
$space_left = $length - strlen($buf) - 1;
if ($e != 0) {
if ($space_left > 20) {
$len = $space_left;
if ($is_utf8) {
$len = $this->UTF8CharBoundary($word, $len);
} elseif (substr($word, $len - 1, 1) == "=") {
$len--;
} elseif (substr($word, $len - 2, 1) == "=") {
$len -= 2;
}
$part = substr($word, 0, $len);
$word = substr($word, $len);
$buf .= ' ' . $part;
$message .= $buf . sprintf("=%s", $this->LE);
} else {
$message .= $buf . $soft_break;
}
$buf = '';
}
while (strlen($word) > 0) {
$len = $length;
if ($is_utf8) {
$len = $this->UTF8CharBoundary($word, $len);
} elseif (substr($word, $len - 1, 1) == "=") {
$len--;
} elseif (substr($word, $len - 2, 1) == "=") {
$len -= 2;
}
$part = substr($word, 0, $len);
$word = substr($word, $len);
if (strlen($word) > 0) {
$message .= $part . sprintf("=%s", $this->LE);
} else {
$buf = $part;
}
}
} else {
$buf_o = $buf;
$buf .= ($e == 0) ? $word : (' ' . $word);
if (strlen($buf) > $length and $buf_o != '') {
$message .= $buf_o . $soft_break;
$buf = $word;
}
}
}
$message .= $buf . $this->LE;
}
return $message;
}

The documentation for this class was generated from the following files: