Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 16.19 KB | None | 0 0
  1.  
  2.  
  3. class phpmailer.php
  4. [PHP]
  5. <?php
  6. /**
  7.  * PHPMailer - PHP email creation and transport class.
  8.  * PHP Version 5
  9.  * @package PHPMailer
  10.  * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
  11.  * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
  12.  * @author Jim Jagielski (jimjag) <jimjag@gmail.com>
  13.  * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
  14.  * @author Brent R. Matzelle (original founder)
  15.  * @copyright 2012 - 2014 Marcus Bointon
  16.  * @copyright 2010 - 2012 Jim Jagielski
  17.  * @copyright 2004 - 2009 Andy Prevost
  18.  * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
  19.  * @note This program is distributed in the hope that it will be useful - WITHOUT
  20.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  21.  * FITNESS FOR A PARTICULAR PURPOSE.
  22.  */
  23.  
  24. /**
  25.  * PHPMailer - PHP email creation and transport class.
  26.  * @package PHPMailer
  27.  * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
  28.  * @author Jim Jagielski (jimjag) <jimjag@gmail.com>
  29.  * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
  30.  * @author Brent R. Matzelle (original founder)
  31.  */
  32. class PHPMailer
  33. {
  34.     /**
  35.      * The PHPMailer Version number.
  36.      * @type string
  37.      */
  38.     public $Version = '5.2.13';
  39.  
  40.     /**
  41.      * Email priority.
  42.      * Options: null (default), 1 = High, 3 = Normal, 5 = low.
  43.      * When null, the header is not set at all.
  44.      * @type integer
  45.      */
  46.     public $Priority = null;
  47.  
  48.     /**
  49.      * The character set of the message.
  50.      * @type string
  51.      */
  52.     public $CharSet = 'iso-8859-1';
  53.  
  54.     /**
  55.      * The MIME Content-type of the message.
  56.      * @type string
  57.      */
  58.     public $ContentType = 'text/plain';
  59.  
  60.     /**
  61.      * The message encoding.
  62.      * Options: "8bit", "7bit", "binary", "base64", and "quoted-printable".
  63.      * @type string
  64.      */
  65.     public $Encoding = '8bit';
  66.  
  67.     /**
  68.      * Holds the most recent mailer error message.
  69.      * @type string
  70.      */
  71.     public $ErrorInfo = '';
  72.  
  73.     /**
  74.      * The From email address for the message.
  75.      * @type string
  76.      */
  77.     public $From = 'root@localhost';
  78.  
  79.     /**
  80.      * The From name of the message.
  81.      * @type string
  82.      */
  83.     public $FromName = 'Root User';
  84.  
  85.     /**
  86.      * The Sender email (Return-Path) of the message.
  87.      * If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
  88.      * @type string
  89.      */
  90.     public $Sender = '';
  91.  
  92.     /**
  93.      * The Return-Path of the message.
  94.      * If empty, it will be set to either From or Sender.
  95.      * @type string
  96.      * @deprecated Email senders should never set a return-path header;
  97.      * it's the receiver's job (RFC5321 section 4.4), so this no longer does anything.
  98.      * @link https://tools.ietf.org/html/rfc5321#section-4.4 RFC5321 reference
  99.      */
  100.     public $ReturnPath = '';
  101.  
  102.     /**
  103.      * The Subject of the message.
  104.      * @type string
  105.      */
  106.     public $Subject = '';
  107.  
  108.     /**
  109.      * An HTML or plain text message body.
  110.      * If HTML then call isHTML(true).
  111.      * @type string
  112.      */
  113.     public $Body = '';
  114.  
  115.     /**
  116.      * The plain-text message body.
  117.      * This body can be read by mail clients that do not have HTML email
  118.      * capability such as mutt & Eudora.
  119.      * Clients that can read HTML will view the normal Body.
  120.      * @type string
  121.      */
  122.     public $AltBody = '';
  123.  
  124.     /**
  125.      * An iCal message part body.
  126.      * Only supported in simple alt or alt_inline message types
  127.      * To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator
  128.      * @link http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/
  129.      * @link http://kigkonsult.se/iCalcreator/
  130.      * @type string
  131.      */
  132.     public $Ical = '';
  133.  
  134.     /**
  135.      * The complete compiled MIME message body.
  136.      * @access protected
  137.      * @type string
  138.      */
  139.     protected $MIMEBody = '';
  140.  
  141.     /**
  142.      * The complete compiled MIME message headers.
  143.      * @type string
  144.      * @access protected
  145.      */
  146.     protected $MIMEHeader = '';
  147.  
  148.     /**
  149.      * Extra headers that createHeader() doesn't fold in.
  150.      * @type string
  151.      * @access protected
  152.      */
  153.     protected $mailHeader = '';
  154.  
  155.     /**
  156.      * Word-wrap the message body to this number of chars.
  157.      * Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance.
  158.      * @type integer
  159.      */
  160.     public $WordWrap = 0;
  161.  
  162.     /**
  163.      * Which method to use to send mail.
  164.      * Options: "mail", "sendmail", or "smtp".
  165.      * @type string
  166.      */
  167.     public $Mailer = 'mail';
  168.  
  169.     /**
  170.      * The path to the sendmail program.
  171.      * @type string
  172.      */
  173.     public $Sendmail = '/usr/sbin/sendmail';
  174.  
  175.     /**
  176.      * Whether mail() uses a fully sendmail-compatible MTA.
  177.      * One which supports sendmail's "-oi -f" options.
  178.      * @type boolean
  179.      */
  180.     public $UseSendmailOptions = true;
  181.  
  182.     /**
  183.      * Path to PHPMailer plugins.
  184.      * Useful if the SMTP class is not in the PHP include path.
  185.      * @type string
  186.      * @deprecated Should not be needed now there is an autoloader.
  187.      */
  188.     public $PluginDir = '';
  189.  
  190.     /**
  191.      * The email address that a reading confirmation should be sent to.
  192.      * @type string
  193.      */
  194.     public $ConfirmReadingTo = '';
  195.  
  196.     /**
  197.      * The hostname to use in the Message-ID header and as default HELO string.
  198.      * If empty, PHPMailer attempts to find one with, in order,
  199.      * $_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the value
  200.      * 'localhost.localdomain'.
  201.      * @type string
  202.      */
  203.     public $Hostname = '';
  204.  
  205.     /**
  206.      * An ID to be used in the Message-ID header.
  207.      * If empty, a unique id will be generated.
  208.      * @type string
  209.      */
  210.     public $MessageID = '';
  211.  
  212.     /**
  213.      * The message Date to be used in the Date header.
  214.      * If empty, the current date will be added.
  215.      * @type string
  216.      */
  217.     public $MessageDate = '';
  218.  
  219.     /**
  220.      * SMTP hosts.
  221.      * Either a single hostname or multiple semicolon-delimited hostnames.
  222.      * You can also specify a different port
  223.      * for each host by using this format: [hostname:port]
  224.      * (e.g. "smtp1.example.com:25;smtp2.example.com").
  225.      * You can also specify encryption type, for example:
  226.      * (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465").
  227.      * Hosts will be tried in order.
  228.      * @type string
  229.      */
  230.     public $Host = 'poczta.o2.pl';
  231.  
  232.     /**
  233.      * The default SMTP server port.
  234.      * @type integer
  235.      * @TODO Why is this needed when the SMTP class takes care of it?
  236.      */
  237.     public $Port = 25;
  238.  
  239.     /**
  240.      * The SMTP HELO of the message.
  241.      * Default is $Hostname. If $Hostname is empty, PHPMailer attempts to find
  242.      * one with the same method described above for $Hostname.
  243.      * @type string
  244.      * @see PHPMailer::$Hostname
  245.      */
  246.     public $Helo = '';
  247.  
  248.     /**
  249.      * What kind of encryption to use on the SMTP connection.
  250.      * Options: '', 'ssl' or 'tls'
  251.      * @type string
  252.      */
  253.     public $SMTPSecure = '';
  254.  
  255.     /**
  256.      * Whether to enable TLS encryption automatically if a server supports it,
  257.      * even if `SMTPSecure` is not set to 'tls'.
  258.      * Be aware that in PHP >= 5.6 this requires that the server's certificates are valid.
  259.      * @type boolean
  260.      */
  261.     public $SMTPAutoTLS = true;
  262.  
  263.     /**
  264.      * Whether to use SMTP authentication.
  265.      * Uses the Username and Password properties.
  266.      * @type boolean
  267.      * @see PHPMailer::$Username
  268.      * @see PHPMailer::$Password
  269.      */
  270.     public $SMTPAuth = true;
  271.  
  272.     /**
  273.      * Options array passed to stream_context_create when connecting via SMTP.
  274.      * @type array
  275.      */
  276.     public $SMTPOptions = array();
  277.  
  278.     /**
  279.      * SMTP username.
  280.      * @type string
  281.      */
  282.     public $Username = 'solaris@o2.pl';
  283.  
  284.     /**
  285.      * SMTP password.
  286.      * @type string
  287.      */
  288.     public $Password = 'pass';
  289.  
  290.     /**
  291.      * SMTP auth type.
  292.      * Options are LOGIN (default), PLAIN, NTLM, CRAM-MD5
  293.      * @type string
  294.      */
  295.     public $AuthType = '';
  296.  
  297.     /**
  298.      * SMTP realm.
  299.      * Used for NTLM auth
  300.      * @type string
  301.      */
  302.     public $Realm = '';
  303.  
  304.     /**
  305.      * SMTP workstation.
  306.      * Used for NTLM auth
  307.      * @type string
  308.      */
  309.     public $Workstation = '';
  310.  
  311.     /**
  312.      * The SMTP server timeout in seconds.
  313.      * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
  314.      * @type integer
  315.      */
  316.     public $Timeout = 300;
  317.  
  318.     /**
  319.      * SMTP class debug output mode.
  320.      * Debug output level.
  321.      * Options:
  322.      * * `0` No output
  323.      * * `1` Commands
  324.      * * `2` Data and commands
  325.      * * `3` As 2 plus connection status
  326.      * * `4` Low-level data output
  327.      * @type integer
  328.      * @see SMTP::$do_debug
  329.      */
  330.     public $SMTPDebug = 1;
  331.  
  332.     /**
  333.      * How to handle debug output.
  334.      * Options:
  335.      * * `echo` Output plain-text as-is, appropriate for CLI
  336.      * * `html` Output escaped, line breaks converted to `<br>`, appropriate for browser output
  337.      * * `error_log` Output to error log as configured in php.ini
  338.      *
  339.      * Alternatively, you can provide a callable expecting two params: a message string and the debug level:
  340.      * <code>
  341.      * $mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
  342.      * </code>
  343.      * @type string|callable
  344.      * @see SMTP::$Debugoutput
  345.      */
  346.     public $Debugoutput = 'echo';
  347.  
  348.     /**
  349.      * Whether to keep SMTP connection open after each message.
  350.      * If this is set to true then to close the connection
  351.      * requires an explicit call to smtpClose().
  352.      * @type boolean
  353.      */
  354.     public $SMTPKeepAlive = false;
  355.  
  356.     /**
  357.      * Whether to split multiple to addresses into multiple messages
  358.      * or send them all in one message.
  359.      * @type boolean
  360.      */
  361.     public $SingleTo = false;
  362.  
  363.     /**
  364.      * Storage for addresses when SingleTo is enabled.
  365.      * @type array
  366.      * @TODO This should really not be public
  367.      */
  368.     public $SingleToArray = array();
  369.  
  370.     /**
  371.      * Whether to generate VERP addresses on send.
  372.      * Only applicable when sending via SMTP.
  373.      * @link https://en.wikipedia.org/wiki/Variable_envelope_return_path
  374.      * @link http://www.postfix.org/VERP_README.html Postfix VERP info
  375.      * @type boolean
  376.      */
  377.     public $do_verp = false;
  378.  
  379.     /**
  380.      * Whether to allow sending messages with an empty body.
  381.      * @type boolean
  382.      */
  383.     public $AllowEmpty = false;
  384.  
  385.     /**
  386.      * The default line ending.
  387.      * @note The default remains "\n". We force CRLF where we know
  388.      *        it must be used via self::CRLF.
  389.      * @type string
  390.      */
  391.     public $LE = "\n";
  392.  
  393.     /**
  394.      * DKIM selector.
  395.      * @type string
  396.      */
  397.     public $DKIM_selector = '';
  398.  
  399.     /**
  400.      * DKIM Identity.
  401.      * Usually the email address used as the source of the email
  402.      * @type string
  403.      */
  404.     public $DKIM_identity = '';
  405.  
  406.     /**
  407.      * DKIM passphrase.
  408.      * Used if your key is encrypted.
  409.      * @type string
  410.      */
  411.     public $DKIM_passphrase = '';
  412.  
  413.     /**
  414.      * DKIM signing domain name.
  415.      * @example 'example.com'
  416.      * @type string
  417.      */
  418.     public $DKIM_domain = '';
  419.  
  420.     /**
  421.      * DKIM private key file path.
  422.      * @type string
  423.      */
  424.     public $DKIM_private = '';
  425.  
  426.     /**
  427.      * Callback Action function name.
  428.      *
  429.      * The function that handles the result of the send email action.
  430.      * It is called out by send() for each email sent.
  431.      *
  432.      * Value can be any php callable: http://www.php.net/is_callable
  433.      *
  434.      * Parameters:
  435.      *   boolean $result        result of the send action
  436.      *   string  $to            email address of the recipient
  437.      *   string  $cc            cc email addresses
  438.      *   string  $bcc           bcc email addresses
  439.      *   string  $subject       the subject
  440.      *   string  $body          the email body
  441.      *   string  $from          email address of sender
  442.      * @type string
  443.      */
  444.     public $action_function = '';
  445.  
  446.     /**
  447.      * What to put in the X-Mailer header.
  448.      * Options: An empty string for PHPMailer default, whitespace for none, or a string to use
  449.      * @type string
  450.      */
  451.     public $XMailer = '';
  452.  
  453.     /**
  454.      * Only For XOAUTH - Google
  455.      * Options: An empty string for PHPMailer default, Enter the email used to get access token
  456.      * @type string
  457.      */
  458. //    public $UserEmail = '';
  459. //    public $RefreshToken = '';
  460. //    public $ClientId = '';
  461. //    public $ClientSecret = '';
  462.  
  463.  
  464.     /**
  465.      * An instance of the SMTP sender class.
  466.      * @type SMTP
  467.      * @access protected
  468.      */
  469.     protected $smtp = null;
  470.  
  471.     /**
  472.      * The array of 'to' addresses.
  473.      * @type array
  474.      * @access protected
  475.      */
  476.     protected $to = array();
  477.  
  478.     /**
  479.      * The array of 'cc' addresses.
  480.      * @type array
  481.      * @access protected
  482.      */
  483.     protected $cc = array();
  484.  
  485.     /**
  486.      * The array of 'bcc' addresses.
  487.      * @type array
  488.      * @access protected
  489.      */
  490.     protected $bcc = array();
  491.  
  492.     /**
  493.      * The array of reply-to names and addresses.
  494.      * @type array
  495.      * @access protected
  496.      */
  497.     protected $ReplyTo = array();
  498.  
  499.     /**
  500.      * An array of all kinds of addresses.
  501.      * Includes all of $to, $cc, $bcc
  502.      * @type array
  503.      * @access protected
  504.      */
  505.     protected $all_recipients = array();
  506.  
  507.     /**
  508.      * The array of attachments.
  509.      * @type array
  510.      * @access protected
  511.      */
  512.     protected $attachment = array();
  513.  
  514.     /**
  515.      * The array of custom headers.
  516.      * @type array
  517.      * @access protected
  518.      */
  519.     protected $CustomHeader = array();
  520.  
  521.     /**
  522.      * The most recent Message-ID (including angular brackets).
  523.      * @type string
  524.      * @access protected
  525.      */
  526.     protected $lastMessageID = '';
  527.  
  528.     /**
  529.      * The message's MIME type.
  530.      * @type string
  531.      * @access protected
  532.      */
  533.     protected $message_type = '';
  534.  
  535.     /**
  536.      * The array of MIME boundary strings.
  537.      * @type array
  538.      * @access protected
  539.      */
  540.     protected $boundary = array();
  541.  
  542.     /**
  543.      * The array of available languages.
  544.      * @type array
  545.      * @access protected
  546.      */
  547.     protected $language = array();
  548.  
  549.     /**
  550.      * The number of errors encountered.
  551.      * @type integer
  552.      * @access protected
  553.      */
  554.     protected $error_count = 0;
  555.  
  556.     /**
  557.      * The S/MIME certificate file path.
  558.      * @type string
  559.      * @access protected
  560.      */
  561.     protected $sign_cert_file = '';
  562.  
  563.     /**
  564.      * The S/MIME key file path.
  565.      * @type string
  566.      * @access protected
  567.      */
  568.     protected $sign_key_file = '';
  569.  
  570.     /**
  571.      * The optional S/MIME extra certificates ("CA Chain") file path.
  572.      * @type string
  573.      * @access protected
  574.      */
  575.     protected $sign_extracerts_file = '';
  576.  
  577.     /**
  578.      * The S/MIME password for the key.
  579.      * Used only if the key is encrypted.
  580.      * @type string
  581.      * @access protected
  582.      */
  583.     protected $sign_key_pass = '';
  584.  
  585.     /**
  586.      * Whether to throw exceptions for errors.
  587.      * @type boolean
  588.      * @access protected
  589.      */
  590.     protected $exceptions = false;
  591.  
  592.     /**
  593.      * Unique ID used for message ID and boundaries.
  594.      * @type string
  595.      * @access protected
  596.      */
  597.     protected $uniqueid = '';
  598.  
  599.     /**
  600.      * Error severity: message only, continue processing.
  601.      */
  602.     const STOP_MESSAGE = 0;
  603.  
  604.     /**
  605.      * Error severity: message, likely ok to continue processing.
  606.      */
  607.     const STOP_CONTINUE = 1;
  608.  
  609.     /**
  610.      * Error severity: message, plus full stop, critical error reached.
  611.      */
  612.     const STOP_CRITICAL = 2;
  613.  
  614.     /**
  615.      * SMTP RFC standard line ending.
  616.      */
  617.     const CRLF = "\r\n";
  618.  
  619.     /**
  620.      * The maximum line length allowed by RFC 2822 section 2.1.1
  621.      * @type integer
  622.      */
  623.     const MAX_LINE_LENGTH = 998;
  624.  
  625.     /**
  626.      * Constructor.
  627.      * @param boolean $exceptions Should we throw external exceptions?
  628.      */
  629.     public function __construct($exceptions = false)
  630.     {
  631.         $this->exceptions = (boolean)$exceptions;
  632.   }
  633.      [/PHP]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement