\PHPMailer
PHP email creation and transport class
Synopsis
class PHPMailer
{
- // constants
- const STOP_MESSAGE = 0;
- const STOP_CONTINUE = 1;
- const STOP_CRITICAL = 2;
- const CRLF = "\r\n";
- // members
- public $Priority;
- public $CharSet;
- public $ContentType;
- public $Encoding;
- public $ErrorInfo;
- public $From;
- public $FromName;
- public $Sender;
- public $ReturnPath;
- public $Subject;
- public $Body;
- public $AltBody;
- public $Ical;
- protected $MIMEBody;
- protected $MIMEHeader;
- protected $mailHeader;
- public $WordWrap;
- public $Mailer;
- public $Sendmail;
- public $UseSendmailOptions;
- public $PluginDir;
- public $ConfirmReadingTo;
- public $Hostname;
- public $MessageID;
- public $MessageDate;
- public $Host;
- public $Port;
- public $Helo;
- public $SMTPSecure;
- public bool $SMTPAuth;
- public $Username;
- public $Password;
- public $AuthType;
- public $Realm;
- public $Workstation;
- public $Timeout;
- public bool $SMTPDebug;
- public $Debugoutput;
- public bool $SMTPKeepAlive;
- public bool $SingleTo;
- public bool $do_verp;
- public bool $SingleToArray;
- public bool $AllowEmpty;
- public $LE;
- public $DKIM_selector;
- public $DKIM_identity;
- public $DKIM_passphrase;
- public $DKIM_domain;
- public $DKIM_private;
- public $action_function;
- public $Version;
- public $XMailer;
- protected SMTP $smtp;
- protected $to;
- protected $cc;
- protected $bcc;
- protected $ReplyTo;
- protected $all_recipients;
- protected $attachment;
- protected $CustomHeader;
- protected $message_type;
- protected $boundary;
- protected $language;
- protected $error_count;
- protected $sign_cert_file;
- protected $sign_key_file;
- protected $sign_key_pass;
- protected $exceptions;
- // methods
- private bool mail_passthru()
- protected void edebug()
- public void __construct()
- public void __destruct()
- public void IsHTML()
- public void IsSMTP()
- public void IsMail()
- public void IsSendmail()
- public void IsQmail()
- public boolean AddAddress()
- public boolean AddCC()
- public boolean AddBCC()
- public boolean AddReplyTo()
- protected boolean AddAnAddress()
- public boolean SetFrom()
- public static boolean ValidateAddress()
- public bool Send()
- public bool PreSend()
- public bool PostSend()
- protected bool SendmailSend()
- protected bool MailSend()
- protected bool SmtpSend()
- public bool SmtpConnect()
- public void SmtpClose()
- public bool SetLanguage()
- public array GetTranslations()
- public string AddrAppend()
- public string AddrFormat()
- public string WrapText()
- public int UTF8CharBoundary()
- public void SetWordWrap()
- public string CreateHeader()
- public string GetMailMIME()
- public string GetSentMIMEMessage()
- public string CreateBody()
- protected string GetBoundary()
- protected string EndBoundary()
- protected void SetMessageType()
- public string HeaderLine()
- public string TextLine()
- public bool AddAttachment()
- public array GetAttachments()
- protected string AttachAll()
- protected string EncodeFile()
- public string EncodeString()
- public string EncodeHeader()
- public bool HasMultiBytes()
- public string Base64EncodeWrapMB()
- public string EncodeQP()
- public string EncodeQPphp()
- public string EncodeQ()
- public void AddStringAttachment()
- public bool AddEmbeddedImage()
- public bool AddStringEmbeddedImage()
- public bool InlineImageExists()
- public bool AttachmentExists()
- public bool AlternativeExists()
- public void ClearAddresses()
- public void ClearCCs()
- public void ClearBCCs()
- public void ClearReplyTos()
- public void ClearAllRecipients()
- public void ClearAttachments()
- public void ClearCustomHeaders()
- protected void SetError()
- public static string RFCDate()
- protected string ServerHostname()
- protected string Lang()
- public bool IsError()
- public string FixEOL()
- public void AddCustomHeader()
- public string MsgHTML()
- public string html2text()
- public static string _mime_types()
- public static string filenameToType()
- public static string|array mb_pathinfo()
- public bool set()
- public string SecureHeader()
- public static string NormalizeBreaks()
- public void Sign()
- public string DKIM_QP()
- public string DKIM_Sign()
- public string DKIM_HeaderC()
- public string DKIM_BodyC()
- public string DKIM_Add()
- protected void doCallback()
Hierarchy
Extended by
Tasks
Tasks
Line | Task |
---|---|
2725+ | Should this not be using __set() magic function? |
Constants
Name | Value |
---|---|
STOP_MESSAGE | 0 |
STOP_CONTINUE | 1 |
STOP_CRITICAL | 2 |
CRLF | "\r\n" |
Members
protected
- $CustomHeader — array
- $MIMEBody
—
string
Stores the complete compiled MIME message body. - $MIMEHeader
—
string
Stores the complete compiled MIME message headers. - $ReplyTo — array
- $all_recipients — array
- $attachment — array
- $bcc — array
- $boundary — array
- $cc — array
- $error_count — integer
- $exceptions — boolean
- $language — array
- $mailHeader
—
string
Stores the extra header list which CreateHeader() doesn't fold in - $message_type — string
- $sign_cert_file — string
- $sign_key_file — string
- $sign_key_pass — string
- $smtp — SMTP
- $to — array
public
- $AllowEmpty
—
bool
Should we allow sending messages with empty body? - $AltBody
—
string
The plain-text message body. -
$AuthType
Sets SMTP auth type. Options are LOGIN | PLAIN | NTLM | CRAM-MD5 (default LOGIN) @var string - $Body
—
string
An HTML or plain text message body. - $CharSet
—
string
Sets the CharSet of the message. - $ConfirmReadingTo
—
string
Sets the email address that a reading confirmation will be sent. - $ContentType
—
string
Sets the Content-type of the message. - $DKIM_domain
—
string
Used with DKIM Singing required if DKIM is enabled, in format of email address 'domain.com' - $DKIM_identity
—
string
Used with DKIM Signing required if DKIM is enabled, in format of email address 'you@yourdomain.com' typically used as the source of the email - $DKIM_passphrase
—
string
Used with DKIM Signing optional parameter if your private key requires a passphras - $DKIM_private
—
string
Used with DKIM Signing required if DKIM is enabled, path to private key file - $DKIM_selector
—
string
Used with DKIM Signing required parameter if DKIM is enabled - $Debugoutput
—
string
Sets the function/method to use for debugging output. - $Encoding
—
string
Sets the Encoding of the message. Options for this are "8bit", "7bit", "binary", "base64", and "quoted-printable". - $ErrorInfo
—
string
Holds the most recent mailer error message. - $From
—
string
Sets the From email address for the message. - $FromName
—
string
Sets the From name of the message. - $Helo
—
string
Sets the SMTP HELO of the message (Default is $Hostname). - $Host
—
string
Sets the SMTP hosts. - $Hostname
—
string
Sets the hostname to use in Message-Id and Received headers and as default HELO string. If empty, the value returned by SERVER_NAME is used or 'localhost.localdomain'. - $Ical
—
string
An iCal message part body Only supported in simple alt or alt_inline message types To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator - $LE
—
string
Provides the ability to change the generic line ending NOTE: The default remains '\n'. We force CRLF where we KNOW it must be used via self::CRLF - $Mailer
—
string
Method to send mail: ("mail", "sendmail", or "smtp"). - $MessageDate
—
string
Sets the message Date to be used in the Date header. - $MessageID
—
string
Sets the message ID to be used in the Message-Id header. - $Password
—
string
Sets SMTP password. - $PluginDir
—
string
Path to PHPMailer plugins. Useful if the SMTP class is in a different directory than the PHP include path. - $Port
—
int
Sets the default SMTP server port. - $Priority
—
int
Email priority (1 = High, 3 = Normal, 5 = low). -
$Realm
Sets SMTP realm. - $ReturnPath
—
string
Sets the Return-Path of the message. If empty, it will be set to either From or Sender. - $SMTPAuth
—
bool
Sets SMTP authentication. Utilizes the Username and Password variables. - $SMTPDebug
—
bool
Sets SMTP class debugging on or off. - $SMTPKeepAlive
—
bool
Prevents the SMTP connection from being closed after each mail sending. If this is set to true then to close the connection requires an explicit call to SmtpClose(). - $SMTPSecure
—
string
Sets connection prefix. Options are "", "ssl" or "tls" - $Sender
—
string
Sets the Sender email (Return-Path) of the message. - $Sendmail
—
string
Sets the path of the sendmail program. - $SingleTo
—
bool
Provides the ability to have the TO field process individual emails, instead of sending to entire TO addresses - $SingleToArray
—
bool
If SingleTo is true, this provides the array to hold the email addresses - $Subject
—
string
Sets the Subject of the message. - $Timeout
—
int
Sets the SMTP server timeout in seconds. - $UseSendmailOptions
—
boolean
Determine if mail() uses a fully sendmail compatible MTA that supports sendmail's "-oi -f" options - $Username
—
string
Sets SMTP username. - $Version
—
string
Sets the PHPMailer Version number - $WordWrap
—
int
Sets word wrapping on the body of the message to a given number of characters. -
$Workstation
Sets SMTP workstation. - $XMailer
—
string
What to use in the X-Mailer header - $action_function
—
string
Callback Action function name. - $do_verp
—
bool
Should we generate VERP addresses when sending via SMTP?
Methods
private
- mail_passthru() — Calls actual mail() function, but in a safe_mode aware fashion Also, unless sendmail_path points to sendmail (or something that claims to be sendmail), don't pass params (not a perfect fix, but it will do)
protected
- AddAnAddress() — Adds an address to one of the recipient arrays Addresses that have been added already return false, but do not throw exceptions
- AttachAll() — Attaches all fs, string, and binary attachments to the message.
- EncodeFile() — Encodes attachment in requested format.
- EndBoundary() — Returns the end of a message boundary.
- GetBoundary() — Returns the start of a message boundary.
- Lang() — Returns a message in the appropriate language.
- MailSend() — Sends mail using the PHP mail() function.
- SendmailSend() — Sends mail using the $Sendmail program.
- ServerHostname() — Returns the server hostname or 'localhost.localdomain' if unknown.
- SetError() — Adds the error message to the error container.
- SetMessageType() — Sets the message type.
- SmtpSend() — Sends mail via SMTP using PhpSMTP Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
- doCallback() — Perform callback
- edebug() — Outputs debugging info via user-defined method
public
- __construct() — Constructor
- __destruct() — Destructor
- AddAddress() — Adds a "To" address.
- AddAttachment() — Adds an attachment from a path on the filesystem.
- AddBCC() — Adds a "Bcc" address.
- AddCC() — Adds a "Cc" address.
- AddCustomHeader() — Adds a custom header. $name value can be overloaded to contain both header name and value (name:value)
- AddEmbeddedImage() — Add an embedded attachment from a file.
- AddReplyTo() — Adds a "Reply-to" address.
- AddStringAttachment() — Adds a string or binary attachment (non-filesystem) to the list.
- AddStringEmbeddedImage() — Add an embedded stringified attachment.
- AddrAppend() — Creates recipient headers.
- AddrFormat() — Formats an address correctly.
- AlternativeExists() — Does this message have an alternative body set?
- AttachmentExists() — Returns true if an attachment (non-inline) is present.
- Base64EncodeWrapMB() — Correctly encodes and wraps long multibyte strings for mail headers without breaking lines within a character.
- ClearAddresses() — Clears all recipients assigned in the TO array. Returns void.
- ClearAllRecipients() — Clears all recipients assigned in the TO, CC and BCC array. Returns void.
- ClearAttachments() — Clears all previously set filesystem, string, and binary attachments. Returns void.
- ClearBCCs() — Clears all recipients assigned in the BCC array. Returns void.
- ClearCCs() — Clears all recipients assigned in the CC array. Returns void.
- ClearCustomHeaders() — Clears all custom headers. Returns void.
- ClearReplyTos() — Clears all recipients assigned in the ReplyTo array. Returns void.
- CreateBody() — Assembles the message body. Returns an empty string on failure.
- CreateHeader() — Assembles message header.
- DKIM_Add() — Create the DKIM header, body, as new header
- DKIM_BodyC() — Generate DKIM Canonicalization Body
- DKIM_HeaderC() — Generate DKIM Canonicalization Header
- DKIM_QP() — Set the private key file and password to sign the message.
- DKIM_Sign() — Generate DKIM signature
- EncodeHeader() — Encode a header string to best (shortest) of Q, B, quoted or none.
- EncodeQ() — Encode string to q encoding.
- EncodeQP() — Encode string to RFC2045 (6.7) quoted-printable format
- EncodeQPphp() — Wrapper to preserve BC for old QP encoding function that was removed
- EncodeString() — Encodes string to requested format.
- FixEOL() — Changes every end of line from CRLF, CR or LF to $this->LE.
- GetAttachments() — Return the current array of attachments
- GetMailMIME() — Returns the message MIME.
- GetSentMIMEMessage() — Returns the MIME message (headers and body). Only really valid post PreSend().
- GetTranslations() — Return the current array of language strings
- HasMultiBytes() — Checks if a string contains multibyte characters.
- HeaderLine() — Returns a formatted header line.
- InlineImageExists() — Returns true if an inline attachment is present.
- IsError() — Returns true if an error occurred.
- IsHTML() — Sets message type to HTML.
- IsMail() — Sets Mailer to send message using PHP mail() function.
- IsQmail() — Sets Mailer to send message using the qmail MTA.
- IsSMTP() — Sets Mailer to send message using SMTP.
- IsSendmail() — Sets Mailer to send message using the $Sendmail program.
- MsgHTML() — Creates a message from an HTML string, making modifications for inline images and backgrounds and creates a plain-text version by converting the HTML Overwrites any existing values in $this->Body and $this->AltBody
- NormalizeBreaks() — Normalize UNIX LF, Mac CR and Windows CRLF line breaks into a single line break format Defaults to CRLF (for message bodies) and preserves consecutive breaks
- PostSend() — Actual Email transport function Send the email via the selected mechanism
- PreSend() — Prep mail by constructing all message entities
- RFCDate() — Returns the proper RFC 822 formatted date.
- SecureHeader() — Strips newlines to prevent header injection.
- 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.
- SetFrom() — Set the From and FromName properties
- SetLanguage() — Sets the language for all class error messages.
- SetWordWrap() — Set the body wrapping.
- Sign() — Set the private key file and password to sign the message.
- SmtpClose() — Closes the active SMTP session if one exists.
- SmtpConnect() — Initiates a connection to an SMTP server.
- TextLine() — Returns a formatted mail line.
- UTF8CharBoundary() — Finds last character boundary prior to maxLength in a utf-8 quoted (printable) encoded string.
- ValidateAddress() — Check that a string looks roughly like an email address should Static so it can be used without instantiation, public so people can overload Conforms to RFC5322: Uses *correct* regex on which FILTER_VALIDATE_EMAIL is based; So why not use FILTER_VALIDATE_EMAIL? Because it was broken to not allow a@b type valid addresses :(
- WrapText() — Wraps message for use with mailers that do not automatically perform wrapping and for quoted-printable.
- _mime_types() — Gets the MIME type of the embedded or inline image
- filenameToType() — Try to map a file name to a MIME type, default to application/octet-stream
- html2text() — Convert an HTML string into a plain text version
- mb_pathinfo() — Drop-in replacement for pathinfo(), but multibyte-safe, cross-platform-safe, old-version-safe.
- set() — Set (or reset) Class Objects (variables)