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:
@@ -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!
|
||||
@@ -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!
|
||||
@@ -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');
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user