Add pear modules, mail and net_smtp via composer (#93)

Add pear modules, mail and net_smtp via composer, remove php 5.6 build due to phpunit 6
This commit is contained in:
Thilina Hasantha
2018-01-08 23:13:43 +01:00
committed by GitHub
parent 359e3f8382
commit e7792e7d79
2349 changed files with 117270 additions and 83170 deletions

View File

@@ -0,0 +1,15 @@
.DS_Store
Net_SMTP-*.tgz
# Tests
run-tests.log
/tests/*.diff
/tests/*.exp
/tests/*.log
/tests/*.out
/tests/config.php
# composer related
composer.lock
composer.phar
vendor

View File

@@ -0,0 +1,11 @@
language: php
install:
- pear install package.xml
php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- nightly
script: pear run-tests -d tests/

View File

@@ -0,0 +1,69 @@
--------------------------------------------------------------------
The PHP License, version 3.01
Copyright (c) 2002-2015 Jon Parise and Chuck Hagenbuch.
All rights reserved.
--------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, is permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name "PHP" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact group@php.net.
4. Products derived from this software may not be called "PHP", nor
may "PHP" appear in their name, without prior written permission
from group@php.net. You may indicate that your software works in
conjunction with PHP by saying "Foo for PHP" instead of calling
it "PHP Foo" or "phpfoo"
5. The PHP Group may publish revised and/or new versions of the
license from time to time. Each version will be given a
distinguishing version number.
Once covered code has been published under a particular version
of the license, you may always continue to use it under the terms
of that version. You may also choose to use such covered code
under the terms of any subsequent version of the license
published by the PHP Group. No one other than the PHP Group has
the right to modify the terms applicable to covered code created
under this License.
6. Redistributions of any form whatsoever must retain the following
acknowledgment:
"This product includes PHP software, freely available from
<http://www.php.net/software/>".
THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------
This software consists of voluntary contributions made by many
individuals on behalf of the PHP Group.
The PHP Group can be contacted via Email at group@php.net.
For more information on the PHP Group and the PHP project,
please see <http://www.php.net>.
PHP includes the Zend Engine, freely available at
<http://www.zend.com>.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
docs/guide.txt

View File

@@ -0,0 +1,48 @@
{
"authors": [
{
"email": "jon@php.net",
"name": "Jon Parise",
"homepage": "http://www.indelible.org",
"role": "Lead"
},
{
"email": "chuck@horde.org",
"name": "Chuck Hagenbuch",
"role": "Lead"
}
],
"autoload": {
"psr-0": {
"Net": "./"
}
},
"description": "An implementation of the SMTP protocol",
"keywords": [
"smtp",
"mail",
"email"
],
"include-path": [
"./"
],
"license": "PHP-3.01",
"name": "pear/net_smtp",
"homepage": "http://pear.github.io/Net_SMTP/",
"support": {
"issues": "https://github.com/pear/Net_SMTP/issues",
"source": "https://github.com/pear/Net_SMTP"
},
"type": "library",
"require": {
"php": ">=5.4.0",
"pear/pear-core-minimal": "*",
"pear/net_socket": "*"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"suggest": {
"pear/auth_sasl": "Install optionally via your project's composer.json"
}
}

View File

@@ -0,0 +1,16 @@
[general]
source-link: no
no-datestamp: yes
generator: off
strip-comments: yes
toc-backlinks: no
[standalone reader]
docinfo_xform: no
[html4css1 writer]
stylesheet-path: docutils.css
embed-stylesheet: yes
field-name-limit: 20
cloak-email-addresses: yes
initial-header-level: 2

View File

@@ -0,0 +1,108 @@
body {
font-family: Verdana, Helvetica, Arial, sans-serif;
font-size: 0.8em;
letter-spacing: 0.01em;
line-height: 1.5em;
text-align: justify;
margin: 0 auto;
width: 48em;
}
a:link, a:visited {
color: #00c;
padding-bottom: 0;
text-decoration: none;
border-bottom: 1px solid #dbd5c5;
}
a:hover {
padding-bottom: 0;
border-bottom: 2px solid #dbd5c5;
}
h1, h2, h3 {
font-family: Georgia, "Times New Roman", Times, serif;
font-weight: normal;
line-height: normal;
}
h1 {
font-size: 2.1em;
letter-spacing: -0.02em;
margin-top: 30px;
text-align: center;
}
h2 {
font-size: 1.6em;
font-style: italic;
margin: 30px 0 10px 0;
}
h3 {
font-size: 1.3em;
font-style: italic;
margin-top: 20px;
}
li {
line-height: 135%;
}
ul, ol {
margin: 0 0 1em 2em;
padding: 0 0 0 1em;
}
hr {
background-color: #ccc;
border: 0px none;
color: #eee;
height: 1px;
margin: 30px 0px;
}
blockquote, pre {
background-color: #f9f9f9;
border: 1px solid #eee;
border-left: 2px solid #ccc;
padding: 1em;
}
blockquote {
color: #666;
line-height: 1.3em;
}
pre {
line-height: normal;
overflow: auto;
}
pre.code-block {
padding-bottom: 0;
}
tt, pre, code, samp, kbd {
color: #333;
font-family: Consolas, 'Lucida Console', monospace;
font-size: 13px;
}
label em {
font-weight: normal;
}
form {
margin: 0;
padding: 0;
}
.code-block .err { border: 1px solid #FF0000 } /* Error */
.code-block .k,.kn { color: #369 } /* Keywords */
.code-block .c,.cm,.cp,.c1 { color: #666; font-style: italic } /* Comments */
.code-block .n { color: #000 } /* Names */
.code-block .p { color: #000 } /* Punctuation */
.code-block .nc,.nf,.nn { color: #333; font-weight: bold } /* Symbol Names */
.code-block .s { color: #933 } /* Literal.String */
.code-block .sd { color: #666 } /* Literal.String.Doc */

View File

@@ -0,0 +1,267 @@
======================
The Net_SMTP Package
======================
--------------------
User Documentation
--------------------
:Author: Jon Parise
:Contact: jon@php.net
.. contents:: Table of Contents
.. section-numbering::
Dependencies
============
The ``PEAR_Error`` Class
------------------------
The Net_SMTP package uses the `PEAR_Error`_ class for all of its `error
handling`_.
The ``Net_Socket`` Package
--------------------------
The Net_Socket_ package is used as the basis for all network communications.
Connection options can be specified via the `$socket_options` construction
parameter::
$socket_options = array('ssl' => array('verify_peer_name' => false));
$smtp = new Net_SMTP($host, null, null, false, 0, $socket_options);
**Note:** PHP 5.6 introduced `OpenSSL changes`_. Peer certificate verification
is now enabled by default. Although not recommended, `$socket_options` can be
used to disable peer verification (as shown above).
.. _OpenSSL changes: http://php.net/manual/en/migration56.openssl.php
The ``Auth_SASL`` Package
-------------------------
The `Auth_SASL`_ package is an optional dependency. If it is available, the
Net_SMTP package will be able to support the DIGEST-MD5_ and CRAM-MD5_ SMTP
authentication methods. Otherwise, only the LOGIN_ and PLAIN_ methods will
be available.
Error Handling
==============
All of the Net_SMTP class's public methods return a PEAR_Error_ object if an
error occurs. The standard way to check for a PEAR_Error object is by using
`PEAR::isError()`_::
if (PEAR::isError($error = $smtp->connect())) {
die($error->getMessage());
}
.. _PEAR::isError(): http://pear.php.net/manual/en/core.pear.pear.iserror.php
SMTP Authentication
===================
The Net_SMTP package supports the SMTP authentication standard (as defined
by RFC-2554_). The Net_SMTP package supports the following authentication
methods, in order of preference:
.. _RFC-2554: http://www.ietf.org/rfc/rfc2554.txt
DIGEST-MD5
----------
The DIGEST-MD5 authentication method uses `RSA Data Security Inc.`_'s MD5
Message Digest algorithm. It is considered the most secure method of SMTP
authentication.
**Note:** The DIGEST-MD5 authentication method is only supported if the
AUTH_SASL_ package is available.
.. _RSA Data Security Inc.: http://www.rsasecurity.com/
CRAM-MD5
--------
The CRAM-MD5 authentication method has been superseded by the DIGEST-MD5_
method in terms of security. It is provided here for compatibility with
older SMTP servers that may not support the newer DIGEST-MD5 algorithm.
**Note:** The CRAM-MD5 authentication method is only supported if the
AUTH_SASL_ package is available.
LOGIN
-----
The LOGIN authentication method encrypts the user's password using the
Base64_ encoding scheme. Because decrypting a Base64-encoded string is
trivial, LOGIN is not considered a secure authentication method and should
be avoided.
.. _Base64: http://www.php.net/manual/en/function.base64-encode.php
PLAIN
-----
The PLAIN authentication method sends the user's password in plain text.
This method of authentication is not secure and should be avoided.
Secure Connections
==================
If `secure socket transports`_ have been enabled in PHP, it is possible to
establish a secure connection to the remote SMTP server::
$smtp = new Net_SMTP('ssl://mail.example.com', 465);
This example connects to ``mail.example.com`` on port 465 (a common SMTPS
port) using the ``ssl://`` transport.
.. _secure socket transports: http://www.php.net/transports
Sending Data
============
Message data is sent using the ``data()`` method. The data can be supplied
as a single string or as an open file resource.
If a string is provided, it is passed through the `data quoting`_ system and
sent to the socket connection as a single block. These operations are all
memory-based, so sending large messages may result in high memory usage.
If an open file resource is provided, the ``data()`` method will read the
message data from the file line-by-line. Each chunk will be quoted and sent
to the socket connection individually, reducing the overall memory overhead of
this data sending operation.
Header data can be specified separately from message body data by passing it
as the optional second parameter to ``data()``. This is especially useful
when an open file resource is being used to supply message data because it
allows header fields (like *Subject:*) to be built dynamically at runtime.
::
$smtp->data($fp, "Subject: My Subject");
Data Quoting
============
By default, all outbound string data is quoted in accordance with SMTP
standards. This means that all native Unix (``\n``) and Mac (``\r``) line
endings are converted to Internet-standard CRLF (``\r\n``) line endings.
Also, because the SMTP protocol uses a single leading period (``.``) to signal
an end to the message data, single leading periods in the original data
string are "doubled" (e.g. "``..``").
These string transformation can be expensive when large blocks of data are
involved. For example, the Net_SMTP package is not aware of MIME parts (it
just sees the MIME message as one big string of characters), so it is not
able to skip non-text attachments when searching for characters that may
need to be quoted.
Because of this, it is possible to extend the Net_SMTP class in order to
implement your own custom quoting routine. Just create a new class based on
the Net_SMTP class and reimplement the ``quotedata()`` method::
require 'Net_SMTP.php';
class Net_SMTP_custom extends Net_SMTP
{
function quotedata($data)
{
/* Perform custom data quoting */
}
}
Note that the ``$data`` parameter will be passed to the ``quotedata()``
function `by reference`_. This means that you can operate directly on
``$data``. It also the overhead of copying a large ``$data`` string to and
from the ``quotedata()`` method.
.. _by reference: http://www.php.net/manual/en/language.references.pass.php
Server Responses
================
The Net_SMTP package retains the server's last response for further
inspection. The ``getResponse()`` method returns a 2-tuple (two element
array) containing the server's response code as an integer and the response's
arguments as a string.
Upon a successful connection, the server's greeting string is available via
the ``getGreeting()`` method.
Debugging
=========
The Net_SMTP package contains built-in debugging output routines (disabled by
default). Debugging output must be explicitly enabled via the ``setDebug()``
method::
$smtp->setDebug(true);
The debugging messages will be sent to the standard output stream by default.
If you need more control over the output, you can optionally install your own
debug handler.
::
function debugHandler($smtp, $message)
{
echo "[$smtp->host] $message\n";
}
$smtp->setDebug(true, "debugHandler");
Examples
========
Basic Use
---------
The following script demonstrates how a simple email message can be sent
using the Net_SMTP package::
require 'Net/SMTP.php';
$host = 'mail.example.com';
$from = 'user@example.com';
$rcpt = array('recipient1@example.com', 'recipient2@example.com');
$subj = "Subject: Test Message\n";
$body = "Body Line 1\nBody Line 2";
/* Create a new Net_SMTP object. */
if (! ($smtp = new Net_SMTP($host))) {
die("Unable to instantiate Net_SMTP object\n");
}
/* Connect to the SMTP server. */
if (PEAR::isError($e = $smtp->connect())) {
die($e->getMessage() . "\n");
}
/* Send the 'MAIL FROM:' SMTP command. */
if (PEAR::isError($smtp->mailFrom($from))) {
die("Unable to set sender to <$from>\n");
}
/* Address the message to each of the recipients. */
foreach ($rcpt as $to) {
if (PEAR::isError($res = $smtp->rcptTo($to))) {
die("Unable to add recipient <$to>: " . $res->getMessage() . "\n");
}
}
/* Set the body of the message. */
if (PEAR::isError($smtp->data($subj . "\r\n" . $body))) {
die("Unable to send data\n");
}
/* Disconnect from the SMTP server. */
$smtp->disconnect();
.. _PEAR_Error: http://pear.php.net/manual/en/core.pear.pear-error.php
.. _Net_Socket: http://pear.php.net/package/Net_Socket
.. _Auth_SASL: http://pear.php.net/package/Auth_SASL
.. vim: tabstop=4 shiftwidth=4 softtabstop=4 expandtab textwidth=78 ft=rst:

View File

@@ -0,0 +1,39 @@
<?php
require 'Net/SMTP.php';
$host = 'mail.example.com';
$from = 'user@example.com';
$rcpt = array('recipient1@example.com', 'recipient2@example.com');
$subj = "Subject: Test Message\n";
$body = "Body Line 1\nBody Line 2";
/* Create a new Net_SMTP object. */
if (! ($smtp = new Net_SMTP($host))) {
die("Unable to instantiate Net_SMTP object\n");
}
/* Connect to the SMTP server. */
if (PEAR::isError($e = $smtp->connect())) {
die($e->getMessage() . "\n");
}
$smtp->auth('username','password');
/* Send the 'MAIL FROM:' SMTP command. */
if (PEAR::isError($smtp->mailFrom($from))) {
die("Unable to set sender to <$from>\n");
}
/* Address the message to each of the recipients. */
foreach ($rcpt as $to) {
if (PEAR::isError($res = $smtp->rcptTo($to))) {
die("Unable to add recipient <$to>: " . $res->getMessage() . "\n");
}
}
/* Set the body of the message. */
if (PEAR::isError($smtp->data($subj . "\r\n" . $body))) {
die("Unable to send data\n");
}
/* Disconnect from the SMTP server. */
$smtp->disconnect();

View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<package packagerversion="1.7.1" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
http://pear.php.net/dtd/tasks-1.0.xsd
http://pear.php.net/dtd/package-2.0
http://pear.php.net/dtd/package-2.0.xsd">
<name>Net_SMTP</name>
<channel>pear.php.net</channel>
<summary>An implementation of the SMTP protocol</summary>
<description>Provides an implementation of the SMTP protocol using PEAR&apos;s Net_Socket class.</description>
<lead>
<name>Jon Parise</name>
<user>jon</user>
<email>jon@php.net</email>
<active>yes</active>
</lead>
<lead>
<name>Chuck Hagenbuch</name>
<user>chagenbu</user>
<email>chuck@horde.org</email>
<active>yes</active>
</lead>
<date>2017-01-14</date>
<time>00:00:00</time>
<version>
<release>1.7.3</release>
<api>1.3.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://www.php.net/license/3_01.txt">PHP License</license>
<notes>- Fix MIME boundary size calculation (#34)
- Workaround E_DEPRECATED warning on Auth_SASL::factory() call (#29)
</notes>
<contents>
<dir baseinstalldir="/" name="/">
<file name="LICENSE" role="doc" />
<dir name="docs">
<file name="guide.txt" role="doc" />
</dir> <!-- /docs -->
<dir name="examples">
<file name="basic.php" role="doc" />
</dir> <!-- /examples -->
<dir name="tests">
<file name="auth.phpt" role="test" />
<file name="basic.phpt" role="test" />
<file name="config.php.dist" role="test" />
<file name="quotedata.phpt" role="test" />
</dir> <!-- /tests -->
<file name="Net/SMTP.php" role="php" />
</dir> <!-- / -->
</contents>
<dependencies>
<required>
<php>
<min>5.4.0</min>
</php>
<pearinstaller>
<min>1.4.3</min>
</pearinstaller>
<package>
<name>Net_Socket</name>
<channel>pear.php.net</channel>
<min>1.0.7</min>
</package>
</required>
<optional>
<package>
<name>Auth_SASL</name>
<channel>pear.php.net</channel>
<min>1.0.5</min>
</package>
</optional>
</dependencies>
<phprelease />
</package>

3
lib/composer/vendor/pear/net_smtp/phpdoc.sh vendored Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
phpdoc -f Net/SMTP.php -t docs/api -p -ti "Net_SMTP Package API" -dn Net_SMTP -dc Net_SMTP -ed examples

View File

@@ -0,0 +1,28 @@
--TEST--
Net_SMTP: SMTP Authentication
--SKIPIF--
<?php if (!@include('config.php')) die("skip\n");
--FILE--
<?php
require_once 'Net/SMTP.php';
require_once 'config.php';
if (! ($smtp = new Net_SMTP(TEST_HOSTNAME, TEST_PORT, TEST_LOCALHOST))) {
die("Unable to instantiate Net_SMTP object\n");
}
if (PEAR::isError($e = $smtp->connect())) {
die($e->getMessage() . "\n");
}
if (PEAR::isError($e = $smtp->auth(TEST_AUTH_USER, TEST_AUTH_PASS))) {
die("Authentication failure\n");
}
$smtp->disconnect();
echo 'Success!';
--EXPECT--
Success!

View File

@@ -0,0 +1,42 @@
--TEST--
Net_SMTP: Basic Functionality
--SKIPIF--
<?php if (!@include('config.php')) die("skip\n");
--FILE--
<?php
require_once 'Net/SMTP.php';
require_once 'config.php';
if (! ($smtp = new Net_SMTP(TEST_HOSTNAME, TEST_PORT, TEST_LOCALHOST))) {
die("Unable to instantiate Net_SMTP object\n");
}
if (PEAR::isError($e = $smtp->connect())) {
die($e->getMessage() . "\n");
}
if (PEAR::isError($e = $smtp->auth(TEST_AUTH_USER, TEST_AUTH_PASS))) {
die("Authentication failure\n");
}
if (PEAR::isError($smtp->mailFrom(TEST_FROM))) {
die('Unable to set sender to <' . TEST_FROM . ">\n");
}
if (PEAR::isError($res = $smtp->rcptTo(TEST_TO))) {
die('Unable to add recipient <' . TEST_TO . '>: ' .
$res->getMessage() . "\n");
}
$headers = 'Subject: ' . TEST_SUBJECT;
if (PEAR::isError($smtp->data(TEST_BODY, $headers))) {
die("Unable to send data\n");
}
$smtp->disconnect();
echo 'Success!';
--EXPECT--
Success!

View File

@@ -0,0 +1,15 @@
<?php
/**
* Copy this file to config.php and customize the following values to
* suit your configuration.
*/
define('TEST_HOSTNAME', 'localhost');
define('TEST_PORT', 25);
define('TEST_LOCALHOST', 'localhost');
define('TEST_AUTH_USER', 'jon');
define('TEST_AUTH_PASS', 'secret');
define('TEST_FROM', 'from@example.com');
define('TEST_TO', 'to@example.com');
define('TEST_SUBJECT', 'Test Subject');
define('TEST_BODY', 'Test Body');

View File

@@ -0,0 +1,70 @@
--TEST--
Net_SMTP: quotedata()
--FILE--
<?php
require_once 'Net/SMTP.php';
$tests = array(
/* Newlines */
"\n" => "\r\n",
"\r\n" => "\r\n",
"\nxx" => "\r\nxx",
"xx\n" => "xx\r\n",
"xx\nxx" => "xx\r\nxx",
"\n\nxx" => "\r\n\r\nxx",
"xx\n\nxx" => "xx\r\n\r\nxx",
"xx\n\n" => "xx\r\n\r\n",
"\r\nxx" => "\r\nxx",
"xx\r\n" => "xx\r\n",
"xx\r\nxx" => "xx\r\nxx",
"\r\n\r\nxx" => "\r\n\r\nxx",
"xx\r\n\r\nxx" => "xx\r\n\r\nxx",
"xx\r\n\r\n" => "xx\r\n\r\n",
"\r\n\nxx" => "\r\n\r\nxx",
"\n\r\nxx" => "\r\n\r\nxx",
"xx\r\n\nxx" => "xx\r\n\r\nxx",
"xx\n\r\nxx" => "xx\r\n\r\nxx",
"xx\r\n\n" => "xx\r\n\r\n",
"xx\n\r\n" => "xx\r\n\r\n",
"\r" => "\r\n",
"\rxx" => "\r\nxx",
"xx\rxx" => "xx\r\nxx",
"xx\r" => "xx\r\n",
"\r\r" => "\r\n\r\n",
"\r\rxx" => "\r\n\r\nxx",
"xx\r\rxx" => "xx\r\n\r\nxx",
"xx\r\r" => "xx\r\n\r\n",
"xx\rxx\nxx\r\nxx" => "xx\r\nxx\r\nxx\r\nxx",
"\r\r\n\n" => "\r\n\r\n\r\n",
/* Dots */
"." => "..",
"xxx\n." => "xxx\r\n..",
"xxx\n.\nxxx" => "xxx\r\n..\r\nxxx",
"xxx.\n.xxx" => "xxx.\r\n..xxx",
);
function literal($x)
{
return str_replace(array("\r", "\n"), array('\r', '\n'), $x);
}
$smtp = new Net_SMTP();
$error = false;
foreach ($tests as $input => $expected) {
$output = $input;
$smtp->quotedata($output);
if ($output != $expected) {
printf("Error: '%s' => '%s' (expected: '%s')",
literal($input), literal($output), literal($expected));
$error = true;
}
}
if (!$error) {
echo "success\n";
}
--EXPECT--
success