Adding swift mailer
This commit is contained in:
@@ -55,7 +55,12 @@ UserAdapter.method('changePassword', function() {
|
||||
});
|
||||
|
||||
UserAdapter.method('saveUserSuccessCallBack', function(callBackData,serverData) {
|
||||
this.showMessage("Create User","An email has been sent to "+callBackData['email']+" with a temporary password to login to IceHrm.");
|
||||
var user = callBackData[0];
|
||||
if (callBackData[1]) {
|
||||
this.showMessage("Create User","An email has been sent to "+user['email']+" with a temporary password to login to IceHrm.");
|
||||
} else {
|
||||
this.showMessage("Create User","User created successfully. But there was a problem sending welcome email.");
|
||||
}
|
||||
this.get([]);
|
||||
});
|
||||
|
||||
@@ -76,7 +81,7 @@ UserAdapter.method('save', function() {
|
||||
var validator = new FormValidation(this.getTableName()+"_submit",true,{'ShowPopup':false,"LabelErrorClass":"error"});
|
||||
if(validator.checkValues()){
|
||||
var params = validator.getFormParameters();
|
||||
|
||||
|
||||
var msg = this.doCustomValidation(params);
|
||||
if(msg == null){
|
||||
var id = $('#'+this.getTableName()+"_submit #id").val();
|
||||
@@ -84,63 +89,63 @@ UserAdapter.method('save', function() {
|
||||
$(params).attr('id',id);
|
||||
this.add(params,[]);
|
||||
}else{
|
||||
|
||||
|
||||
var reqJson = JSON.stringify(params);
|
||||
|
||||
|
||||
var callBackData = [];
|
||||
callBackData['callBackData'] = [];
|
||||
callBackData['callBackSuccess'] = 'saveUserSuccessCallBack';
|
||||
callBackData['callBackFail'] = 'saveUserFailCallBack';
|
||||
|
||||
|
||||
this.customAction('saveUser','admin=users',reqJson,callBackData);
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
//$("#"+this.getTableName()+'Form .label').html(msg);
|
||||
//$("#"+this.getTableName()+'Form .label').show();
|
||||
this.showMessage("Error Saving User",msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
UserAdapter.method('changePasswordConfirm', function() {
|
||||
$('#adminUsersChangePwd_error').hide();
|
||||
|
||||
var passwordValidation = function (str) {
|
||||
var val = /^[a-zA-Z0-9]\w{6,}$/;
|
||||
return str != null && val.test(str);
|
||||
|
||||
var passwordValidation = function (str) {
|
||||
var val = /^[a-zA-Z0-9]\w{6,}$/;
|
||||
return str != null && val.test(str);
|
||||
};
|
||||
|
||||
|
||||
var password = $('#adminUsersChangePwd #newpwd').val();
|
||||
|
||||
|
||||
if(!passwordValidation(password)){
|
||||
$('#adminUsersChangePwd_error').html("Password may contain only letters, numbers and should be longer than 6 characters");
|
||||
$('#adminUsersChangePwd_error').show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var conPassword = $('#adminUsersChangePwd #conpwd').val();
|
||||
|
||||
|
||||
if(conPassword != password){
|
||||
$('#adminUsersChangePwd_error').html("Passwords don't match");
|
||||
$('#adminUsersChangePwd_error').show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var req = {"id":this.currentId,"pwd":conPassword};
|
||||
var reqJson = JSON.stringify(req);
|
||||
|
||||
|
||||
var callBackData = [];
|
||||
callBackData['callBackData'] = [];
|
||||
callBackData['callBackSuccess'] = 'changePasswordSuccessCallBack';
|
||||
callBackData['callBackFail'] = 'changePasswordFailCallBack';
|
||||
|
||||
|
||||
this.customAction('changePassword','admin=users',reqJson,callBackData);
|
||||
|
||||
|
||||
});
|
||||
|
||||
UserAdapter.method('closeChangePassword', function() {
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
"twig/twig": "1.23.*",
|
||||
"gettext/gettext": "4.0.0",
|
||||
"consolidation/robo": "~1",
|
||||
"filp/whoops": "~2.1"
|
||||
"filp/whoops": "~2.1",
|
||||
"swiftmailer/swiftmailer": "^6.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "5.5.*"
|
||||
|
||||
171
lib/composer/composer.lock
generated
171
lib/composer/composer.lock
generated
@@ -1,10 +1,11 @@
|
||||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "eb7486b98c829f999be2a3a5ce5d48b4",
|
||||
"hash": "1944dee39b7f749b311e58061b00f233",
|
||||
"content-hash": "7a06e9dbeabacf6aec7777ff8b9d4891",
|
||||
"packages": [
|
||||
{
|
||||
"name": "consolidation/annotated-command",
|
||||
@@ -258,6 +259,117 @@
|
||||
"description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
|
||||
"time": "2014-12-30 15:22:37"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/lexer",
|
||||
"version": "v1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/lexer.git",
|
||||
"reference": "83893c552fd2045dd78aef794c31e694c37c0b8c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c",
|
||||
"reference": "83893c552fd2045dd78aef794c31e694c37c0b8c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Doctrine\\Common\\Lexer\\": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.",
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"lexer",
|
||||
"parser"
|
||||
],
|
||||
"time": "2014-09-09 13:34:57"
|
||||
},
|
||||
{
|
||||
"name": "egulias/email-validator",
|
||||
"version": "2.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/egulias/EmailValidator.git",
|
||||
"reference": "1bec00a10039b823cc94eef4eddd47dcd3b2ca04"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/1bec00a10039b823cc94eef4eddd47dcd3b2ca04",
|
||||
"reference": "1bec00a10039b823cc94eef4eddd47dcd3b2ca04",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/lexer": "^1.0.1",
|
||||
"php": ">= 5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"dominicsayers/isemail": "dev-master",
|
||||
"phpunit/phpunit": "^4.8.35",
|
||||
"satooshi/php-coveralls": "^1.0.1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Egulias\\EmailValidator\\": "EmailValidator"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Eduardo Gulias Davis"
|
||||
}
|
||||
],
|
||||
"description": "A library for validating emails against several RFCs",
|
||||
"homepage": "https://github.com/egulias/EmailValidator",
|
||||
"keywords": [
|
||||
"email",
|
||||
"emailvalidation",
|
||||
"emailvalidator",
|
||||
"validation",
|
||||
"validator"
|
||||
],
|
||||
"time": "2017-11-15 23:40:40"
|
||||
},
|
||||
{
|
||||
"name": "filp/whoops",
|
||||
"version": "2.1.10",
|
||||
@@ -763,6 +875,61 @@
|
||||
],
|
||||
"time": "2016-10-10 12:19:37"
|
||||
},
|
||||
{
|
||||
"name": "swiftmailer/swiftmailer",
|
||||
"version": "v6.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/swiftmailer/swiftmailer.git",
|
||||
"reference": "412333372fb6c8ffb65496a2bbd7321af75733fc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/412333372fb6c8ffb65496a2bbd7321af75733fc",
|
||||
"reference": "412333372fb6c8ffb65496a2bbd7321af75733fc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"egulias/email-validator": "~2.0",
|
||||
"php": ">=7.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9.1",
|
||||
"symfony/phpunit-bridge": "~3.3@dev"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "6.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"lib/swift_required.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Chris Corbyn"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"description": "Swiftmailer, free feature-rich PHP mailer",
|
||||
"homepage": "http://swiftmailer.symfony.com",
|
||||
"keywords": [
|
||||
"email",
|
||||
"mail",
|
||||
"mailer"
|
||||
],
|
||||
"time": "2017-09-30 22:39:41"
|
||||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "v3.1.6",
|
||||
|
||||
2
lib/composer/vendor/autoload.php
vendored
2
lib/composer/vendor/autoload.php
vendored
@@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit17bd94f80a35033ddd449fc4168708d6::getLoader();
|
||||
return ComposerAutoloaderInita01cedac3fb3abb6b395843685a2b9da::getLoader();
|
||||
|
||||
8
lib/composer/vendor/composer/ClassLoader.php
vendored
8
lib/composer/vendor/composer/ClassLoader.php
vendored
@@ -13,9 +13,7 @@
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0 class loader
|
||||
*
|
||||
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
|
||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
@@ -39,6 +37,8 @@ namespace Composer\Autoload;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see http://www.php-fig.org/psr/psr-0/
|
||||
* @see http://www.php-fig.org/psr/psr-4/
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
@@ -147,7 +147,7 @@ class ClassLoader
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-0 base directories
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
|
||||
@@ -6,5 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
$vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
'2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
|
||||
);
|
||||
|
||||
@@ -9,4 +9,5 @@ return array(
|
||||
'Twig_' => array($vendorDir . '/twig/twig/lib'),
|
||||
'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src'),
|
||||
'PHPDocsMD' => array($vendorDir . '/victorjonsson/markdowndocs/src'),
|
||||
'Doctrine\\Common\\Lexer\\' => array($vendorDir . '/doctrine/lexer/lib'),
|
||||
);
|
||||
|
||||
@@ -24,6 +24,7 @@ return array(
|
||||
'Interop\\Container\\' => array($vendorDir . '/container-interop/container-interop/src/Interop/Container'),
|
||||
'Gettext\\Languages\\' => array($vendorDir . '/gettext/languages/src'),
|
||||
'Gettext\\' => array($vendorDir . '/gettext/gettext/src'),
|
||||
'Egulias\\EmailValidator\\' => array($vendorDir . '/egulias/email-validator/EmailValidator'),
|
||||
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
|
||||
'DeepCopy\\' => array($vendorDir . '/myclabs/deep-copy/src/DeepCopy'),
|
||||
'Consolidation\\OutputFormatters\\' => array($vendorDir . '/consolidation/output-formatters/src'),
|
||||
|
||||
53
lib/composer/vendor/composer/autoload_real.php
vendored
53
lib/composer/vendor/composer/autoload_real.php
vendored
@@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit17bd94f80a35033ddd449fc4168708d6
|
||||
class ComposerAutoloaderInita01cedac3fb3abb6b395843685a2b9da
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@@ -19,37 +19,52 @@ class ComposerAutoloaderInit17bd94f80a35033ddd449fc4168708d6
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit17bd94f80a35033ddd449fc4168708d6', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInita01cedac3fb3abb6b395843685a2b9da', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit17bd94f80a35033ddd449fc4168708d6', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInita01cedac3fb3abb6b395843685a2b9da', 'loadClassLoader'));
|
||||
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->set($namespace, $path);
|
||||
}
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
|
||||
if ($useStaticLoader) {
|
||||
require_once __DIR__ . '/autoload_static.php';
|
||||
|
||||
$map = require __DIR__ . '/autoload_psr4.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->setPsr4($namespace, $path);
|
||||
}
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInita01cedac3fb3abb6b395843685a2b9da::getInitializer($loader));
|
||||
} else {
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->set($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
$loader->addClassMap($classMap);
|
||||
$map = require __DIR__ . '/autoload_psr4.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->setPsr4($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
$loader->addClassMap($classMap);
|
||||
}
|
||||
}
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
foreach ($includeFiles as $file) {
|
||||
composerRequire17bd94f80a35033ddd449fc4168708d6($file);
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInita01cedac3fb3abb6b395843685a2b9da::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequirea01cedac3fb3abb6b395843685a2b9da($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire17bd94f80a35033ddd449fc4168708d6($file)
|
||||
function composerRequirea01cedac3fb3abb6b395843685a2b9da($fileIdentifier, $file)
|
||||
{
|
||||
require $file;
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
}
|
||||
}
|
||||
|
||||
36
lib/composer/vendor/composer/autoload_static.php
vendored
36
lib/composer/vendor/composer/autoload_static.php
vendored
@@ -4,10 +4,11 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit91d733469d809ee1828b45ab2da48a10
|
||||
class ComposerStaticInita01cedac3fb3abb6b395843685a2b9da
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
'2c102faa651ef8ea5874edb585946bce' => __DIR__ . '/..' . '/swiftmailer/swiftmailer/lib/swift_required.php',
|
||||
);
|
||||
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
@@ -17,6 +18,7 @@ class ComposerStaticInit91d733469d809ee1828b45ab2da48a10
|
||||
),
|
||||
'W' =>
|
||||
array (
|
||||
'Whoops\\' => 7,
|
||||
'Webmozart\\Assert\\' => 17,
|
||||
),
|
||||
'S' =>
|
||||
@@ -55,6 +57,10 @@ class ComposerStaticInit91d733469d809ee1828b45ab2da48a10
|
||||
'Gettext\\Languages\\' => 18,
|
||||
'Gettext\\' => 8,
|
||||
),
|
||||
'E' =>
|
||||
array (
|
||||
'Egulias\\EmailValidator\\' => 23,
|
||||
),
|
||||
'D' =>
|
||||
array (
|
||||
'Doctrine\\Instantiator\\' => 22,
|
||||
@@ -75,6 +81,10 @@ class ComposerStaticInit91d733469d809ee1828b45ab2da48a10
|
||||
1 => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src',
|
||||
2 => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src',
|
||||
),
|
||||
'Whoops\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/filp/whoops/src/Whoops',
|
||||
),
|
||||
'Webmozart\\Assert\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/webmozart/assert/src',
|
||||
@@ -139,6 +149,10 @@ class ComposerStaticInit91d733469d809ee1828b45ab2da48a10
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/gettext/gettext/src',
|
||||
),
|
||||
'Egulias\\EmailValidator\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/egulias/email-validator/EmailValidator',
|
||||
),
|
||||
'Doctrine\\Instantiator\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/doctrine/instantiator/src/Doctrine/Instantiator',
|
||||
@@ -161,6 +175,10 @@ class ComposerStaticInit91d733469d809ee1828b45ab2da48a10
|
||||
),
|
||||
);
|
||||
|
||||
public static $fallbackDirsPsr4 = array (
|
||||
0 => __DIR__ . '/../..' . '/../../src',
|
||||
);
|
||||
|
||||
public static $prefixesPsr0 = array (
|
||||
'T' =>
|
||||
array (
|
||||
@@ -180,6 +198,13 @@ class ComposerStaticInit91d733469d809ee1828b45ab2da48a10
|
||||
0 => __DIR__ . '/..' . '/victorjonsson/markdowndocs/src',
|
||||
),
|
||||
),
|
||||
'D' =>
|
||||
array (
|
||||
'Doctrine\\Common\\Lexer\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/doctrine/lexer/lib',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
public static $classMap = array (
|
||||
@@ -644,10 +669,11 @@ class ComposerStaticInit91d733469d809ee1828b45ab2da48a10
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit91d733469d809ee1828b45ab2da48a10::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit91d733469d809ee1828b45ab2da48a10::$prefixDirsPsr4;
|
||||
$loader->prefixesPsr0 = ComposerStaticInit91d733469d809ee1828b45ab2da48a10::$prefixesPsr0;
|
||||
$loader->classMap = ComposerStaticInit91d733469d809ee1828b45ab2da48a10::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInita01cedac3fb3abb6b395843685a2b9da::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInita01cedac3fb3abb6b395843685a2b9da::$prefixDirsPsr4;
|
||||
$loader->fallbackDirsPsr4 = ComposerStaticInita01cedac3fb3abb6b395843685a2b9da::$fallbackDirsPsr4;
|
||||
$loader->prefixesPsr0 = ComposerStaticInita01cedac3fb3abb6b395843685a2b9da::$prefixesPsr0;
|
||||
$loader->classMap = ComposerStaticInita01cedac3fb3abb6b395843685a2b9da::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
||||
172
lib/composer/vendor/composer/installed.json
vendored
172
lib/composer/vendor/composer/installed.json
vendored
@@ -2490,5 +2490,177 @@
|
||||
"whoops",
|
||||
"zf2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "doctrine/lexer",
|
||||
"version": "v1.0.1",
|
||||
"version_normalized": "1.0.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/lexer.git",
|
||||
"reference": "83893c552fd2045dd78aef794c31e694c37c0b8c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c",
|
||||
"reference": "83893c552fd2045dd78aef794c31e694c37c0b8c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"time": "2014-09-09 13:34:57",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Doctrine\\Common\\Lexer\\": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.",
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"lexer",
|
||||
"parser"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "egulias/email-validator",
|
||||
"version": "2.1.3",
|
||||
"version_normalized": "2.1.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/egulias/EmailValidator.git",
|
||||
"reference": "1bec00a10039b823cc94eef4eddd47dcd3b2ca04"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/1bec00a10039b823cc94eef4eddd47dcd3b2ca04",
|
||||
"reference": "1bec00a10039b823cc94eef4eddd47dcd3b2ca04",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/lexer": "^1.0.1",
|
||||
"php": ">= 5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"dominicsayers/isemail": "dev-master",
|
||||
"phpunit/phpunit": "^4.8.35",
|
||||
"satooshi/php-coveralls": "^1.0.1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
|
||||
},
|
||||
"time": "2017-11-15 23:40:40",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Egulias\\EmailValidator\\": "EmailValidator"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Eduardo Gulias Davis"
|
||||
}
|
||||
],
|
||||
"description": "A library for validating emails against several RFCs",
|
||||
"homepage": "https://github.com/egulias/EmailValidator",
|
||||
"keywords": [
|
||||
"email",
|
||||
"emailvalidation",
|
||||
"emailvalidator",
|
||||
"validation",
|
||||
"validator"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "swiftmailer/swiftmailer",
|
||||
"version": "v6.0.2",
|
||||
"version_normalized": "6.0.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/swiftmailer/swiftmailer.git",
|
||||
"reference": "412333372fb6c8ffb65496a2bbd7321af75733fc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/412333372fb6c8ffb65496a2bbd7321af75733fc",
|
||||
"reference": "412333372fb6c8ffb65496a2bbd7321af75733fc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"egulias/email-validator": "~2.0",
|
||||
"php": ">=7.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9.1",
|
||||
"symfony/phpunit-bridge": "~3.3@dev"
|
||||
},
|
||||
"time": "2017-09-30 22:39:41",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "6.0-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"lib/swift_required.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Chris Corbyn"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"description": "Swiftmailer, free feature-rich PHP mailer",
|
||||
"homepage": "http://swiftmailer.symfony.com",
|
||||
"keywords": [
|
||||
"email",
|
||||
"mail",
|
||||
"mailer"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
19
lib/composer/vendor/doctrine/lexer/LICENSE
vendored
Normal file
19
lib/composer/vendor/doctrine/lexer/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2006-2013 Doctrine Project
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
5
lib/composer/vendor/doctrine/lexer/README.md
vendored
Normal file
5
lib/composer/vendor/doctrine/lexer/README.md
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# Doctrine Lexer
|
||||
|
||||
Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
|
||||
|
||||
This lexer is used in Doctrine Annotations and in Doctrine ORM (DQL).
|
||||
24
lib/composer/vendor/doctrine/lexer/composer.json
vendored
Normal file
24
lib/composer/vendor/doctrine/lexer/composer.json
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "doctrine/lexer",
|
||||
"type": "library",
|
||||
"description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.",
|
||||
"keywords": ["lexer", "parser"],
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"},
|
||||
{"name": "Roman Borschel", "email": "roman@code-factory.org"},
|
||||
{"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "Doctrine\\Common\\Lexer\\": "lib/" }
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
327
lib/composer/vendor/doctrine/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php
vendored
Normal file
327
lib/composer/vendor/doctrine/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php
vendored
Normal file
@@ -0,0 +1,327 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS 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 COPYRIGHT
|
||||
* OWNER OR 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
|
||||
* and is licensed under the MIT license. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Lexer;
|
||||
|
||||
/**
|
||||
* Base class for writing simple lexers, i.e. for creating small DSLs.
|
||||
*
|
||||
* @since 2.0
|
||||
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
* @author Jonathan Wage <jonwage@gmail.com>
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
*/
|
||||
abstract class AbstractLexer
|
||||
{
|
||||
/**
|
||||
* Lexer original input string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $input;
|
||||
|
||||
/**
|
||||
* Array of scanned tokens.
|
||||
*
|
||||
* Each token is an associative array containing three items:
|
||||
* - 'value' : the string value of the token in the input string
|
||||
* - 'type' : the type of the token (identifier, numeric, string, input
|
||||
* parameter, none)
|
||||
* - 'position' : the position of the token in the input string
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $tokens = array();
|
||||
|
||||
/**
|
||||
* Current lexer position in input string.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $position = 0;
|
||||
|
||||
/**
|
||||
* Current peek of current lexer position.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $peek = 0;
|
||||
|
||||
/**
|
||||
* The next token in the input.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $lookahead;
|
||||
|
||||
/**
|
||||
* The last matched/seen token.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $token;
|
||||
|
||||
/**
|
||||
* Sets the input data to be tokenized.
|
||||
*
|
||||
* The Lexer is immediately reset and the new input tokenized.
|
||||
* Any unprocessed tokens from any previous input are lost.
|
||||
*
|
||||
* @param string $input The input to be tokenized.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setInput($input)
|
||||
{
|
||||
$this->input = $input;
|
||||
$this->tokens = array();
|
||||
|
||||
$this->reset();
|
||||
$this->scan($input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the lexer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->lookahead = null;
|
||||
$this->token = null;
|
||||
$this->peek = 0;
|
||||
$this->position = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the peek pointer to 0.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function resetPeek()
|
||||
{
|
||||
$this->peek = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the lexer position on the input to the given position.
|
||||
*
|
||||
* @param integer $position Position to place the lexical scanner.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function resetPosition($position = 0)
|
||||
{
|
||||
$this->position = $position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the original lexer's input until a given position.
|
||||
*
|
||||
* @param integer $position
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInputUntilPosition($position)
|
||||
{
|
||||
return substr($this->input, 0, $position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given token matches the current lookahead.
|
||||
*
|
||||
* @param integer|string $token
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isNextToken($token)
|
||||
{
|
||||
return null !== $this->lookahead && $this->lookahead['type'] === $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether any of the given tokens matches the current lookahead.
|
||||
*
|
||||
* @param array $tokens
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isNextTokenAny(array $tokens)
|
||||
{
|
||||
return null !== $this->lookahead && in_array($this->lookahead['type'], $tokens, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves to the next token in the input string.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function moveNext()
|
||||
{
|
||||
$this->peek = 0;
|
||||
$this->token = $this->lookahead;
|
||||
$this->lookahead = (isset($this->tokens[$this->position]))
|
||||
? $this->tokens[$this->position++] : null;
|
||||
|
||||
return $this->lookahead !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the lexer to skip input tokens until it sees a token with the given value.
|
||||
*
|
||||
* @param string $type The token type to skip until.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function skipUntil($type)
|
||||
{
|
||||
while ($this->lookahead !== null && $this->lookahead['type'] !== $type) {
|
||||
$this->moveNext();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if given value is identical to the given token.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param integer $token
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isA($value, $token)
|
||||
{
|
||||
return $this->getType($value) === $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the lookahead token forward.
|
||||
*
|
||||
* @return array|null The next token or NULL if there are no more tokens ahead.
|
||||
*/
|
||||
public function peek()
|
||||
{
|
||||
if (isset($this->tokens[$this->position + $this->peek])) {
|
||||
return $this->tokens[$this->position + $this->peek++];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Peeks at the next token, returns it and immediately resets the peek.
|
||||
*
|
||||
* @return array|null The next token or NULL if there are no more tokens ahead.
|
||||
*/
|
||||
public function glimpse()
|
||||
{
|
||||
$peek = $this->peek();
|
||||
$this->peek = 0;
|
||||
return $peek;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans the input string for tokens.
|
||||
*
|
||||
* @param string $input A query string.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function scan($input)
|
||||
{
|
||||
static $regex;
|
||||
|
||||
if ( ! isset($regex)) {
|
||||
$regex = sprintf(
|
||||
'/(%s)|%s/%s',
|
||||
implode(')|(', $this->getCatchablePatterns()),
|
||||
implode('|', $this->getNonCatchablePatterns()),
|
||||
$this->getModifiers()
|
||||
);
|
||||
}
|
||||
|
||||
$flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE;
|
||||
$matches = preg_split($regex, $input, -1, $flags);
|
||||
|
||||
foreach ($matches as $match) {
|
||||
// Must remain before 'value' assignment since it can change content
|
||||
$type = $this->getType($match[0]);
|
||||
|
||||
$this->tokens[] = array(
|
||||
'value' => $match[0],
|
||||
'type' => $type,
|
||||
'position' => $match[1],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the literal for a given token.
|
||||
*
|
||||
* @param integer $token
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLiteral($token)
|
||||
{
|
||||
$className = get_class($this);
|
||||
$reflClass = new \ReflectionClass($className);
|
||||
$constants = $reflClass->getConstants();
|
||||
|
||||
foreach ($constants as $name => $value) {
|
||||
if ($value === $token) {
|
||||
return $className . '::' . $name;
|
||||
}
|
||||
}
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regex modifiers
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getModifiers()
|
||||
{
|
||||
return 'i';
|
||||
}
|
||||
|
||||
/**
|
||||
* Lexical catchable patterns.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function getCatchablePatterns();
|
||||
|
||||
/**
|
||||
* Lexical non-catchable patterns.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function getNonCatchablePatterns();
|
||||
|
||||
/**
|
||||
* Retrieve token type. Also processes the token value if necessary.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
abstract protected function getType(&$value);
|
||||
}
|
||||
221
lib/composer/vendor/egulias/email-validator/EmailValidator/EmailLexer.php
vendored
Normal file
221
lib/composer/vendor/egulias/email-validator/EmailValidator/EmailLexer.php
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator;
|
||||
|
||||
use Doctrine\Common\Lexer\AbstractLexer;
|
||||
|
||||
class EmailLexer extends AbstractLexer
|
||||
{
|
||||
//ASCII values
|
||||
const C_DEL = 127;
|
||||
const C_NUL = 0;
|
||||
const S_AT = 64;
|
||||
const S_BACKSLASH = 92;
|
||||
const S_DOT = 46;
|
||||
const S_DQUOTE = 34;
|
||||
const S_OPENPARENTHESIS = 49;
|
||||
const S_CLOSEPARENTHESIS = 261;
|
||||
const S_OPENBRACKET = 262;
|
||||
const S_CLOSEBRACKET = 263;
|
||||
const S_HYPHEN = 264;
|
||||
const S_COLON = 265;
|
||||
const S_DOUBLECOLON = 266;
|
||||
const S_SP = 267;
|
||||
const S_HTAB = 268;
|
||||
const S_CR = 269;
|
||||
const S_LF = 270;
|
||||
const S_IPV6TAG = 271;
|
||||
const S_LOWERTHAN = 272;
|
||||
const S_GREATERTHAN = 273;
|
||||
const S_COMMA = 274;
|
||||
const S_SEMICOLON = 275;
|
||||
const S_OPENQBRACKET = 276;
|
||||
const S_CLOSEQBRACKET = 277;
|
||||
const S_SLASH = 278;
|
||||
const S_EMPTY = null;
|
||||
const GENERIC = 300;
|
||||
const CRLF = 301;
|
||||
const INVALID = 302;
|
||||
const ASCII_INVALID_FROM = 127;
|
||||
const ASCII_INVALID_TO = 199;
|
||||
|
||||
/**
|
||||
* US-ASCII visible characters not valid for atext (@link http://tools.ietf.org/html/rfc5322#section-3.2.3)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $charValue = array(
|
||||
'(' => self::S_OPENPARENTHESIS,
|
||||
')' => self::S_CLOSEPARENTHESIS,
|
||||
'<' => self::S_LOWERTHAN,
|
||||
'>' => self::S_GREATERTHAN,
|
||||
'[' => self::S_OPENBRACKET,
|
||||
']' => self::S_CLOSEBRACKET,
|
||||
':' => self::S_COLON,
|
||||
';' => self::S_SEMICOLON,
|
||||
'@' => self::S_AT,
|
||||
'\\' => self::S_BACKSLASH,
|
||||
'/' => self::S_SLASH,
|
||||
',' => self::S_COMMA,
|
||||
'.' => self::S_DOT,
|
||||
'"' => self::S_DQUOTE,
|
||||
'-' => self::S_HYPHEN,
|
||||
'::' => self::S_DOUBLECOLON,
|
||||
' ' => self::S_SP,
|
||||
"\t" => self::S_HTAB,
|
||||
"\r" => self::S_CR,
|
||||
"\n" => self::S_LF,
|
||||
"\r\n" => self::CRLF,
|
||||
'IPv6' => self::S_IPV6TAG,
|
||||
'{' => self::S_OPENQBRACKET,
|
||||
'}' => self::S_CLOSEQBRACKET,
|
||||
'' => self::S_EMPTY,
|
||||
'\0' => self::C_NUL,
|
||||
);
|
||||
|
||||
protected $hasInvalidTokens = false;
|
||||
|
||||
protected $previous;
|
||||
|
||||
public function reset()
|
||||
{
|
||||
$this->hasInvalidTokens = false;
|
||||
parent::reset();
|
||||
}
|
||||
|
||||
public function hasInvalidTokens()
|
||||
{
|
||||
return $this->hasInvalidTokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $type
|
||||
* @throws \UnexpectedValueException
|
||||
* @return boolean
|
||||
*/
|
||||
public function find($type)
|
||||
{
|
||||
$search = clone $this;
|
||||
$search->skipUntil($type);
|
||||
|
||||
if (!$search->lookahead) {
|
||||
throw new \UnexpectedValueException($type . ' not found');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* getPrevious
|
||||
*
|
||||
* @return array token
|
||||
*/
|
||||
public function getPrevious()
|
||||
{
|
||||
return $this->previous;
|
||||
}
|
||||
|
||||
/**
|
||||
* moveNext
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function moveNext()
|
||||
{
|
||||
$this->previous = $this->token;
|
||||
|
||||
return parent::moveNext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lexical catchable patterns.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getCatchablePatterns()
|
||||
{
|
||||
return array(
|
||||
'[a-zA-Z_]+[46]?', //ASCII and domain literal
|
||||
'[^\x00-\x7F]', //UTF-8
|
||||
'[0-9]+',
|
||||
'\r\n',
|
||||
'::',
|
||||
'\s+?',
|
||||
'.',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lexical non-catchable patterns.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getNonCatchablePatterns()
|
||||
{
|
||||
return array('[\xA0-\xff]+');
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve token type. Also processes the token value if necessary.
|
||||
*
|
||||
* @param string $value
|
||||
* @throws \InvalidArgumentException
|
||||
* @return integer
|
||||
*/
|
||||
protected function getType(&$value)
|
||||
{
|
||||
if ($this->isNullType($value)) {
|
||||
return self::C_NUL;
|
||||
}
|
||||
|
||||
if ($this->isValid($value)) {
|
||||
return $this->charValue[$value];
|
||||
}
|
||||
|
||||
if ($this->isUTF8Invalid($value)) {
|
||||
$this->hasInvalidTokens = true;
|
||||
return self::INVALID;
|
||||
}
|
||||
|
||||
return self::GENERIC;
|
||||
}
|
||||
|
||||
protected function isValid($value)
|
||||
{
|
||||
if (isset($this->charValue[$value])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function isNullType($value)
|
||||
{
|
||||
if ($value === "\0") {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function isUTF8Invalid($value)
|
||||
{
|
||||
if (preg_match('/\p{Cc}+/u', $value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getModifiers()
|
||||
{
|
||||
return 'iu';
|
||||
}
|
||||
}
|
||||
104
lib/composer/vendor/egulias/email-validator/EmailValidator/EmailParser.php
vendored
Normal file
104
lib/composer/vendor/egulias/email-validator/EmailValidator/EmailParser.php
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator;
|
||||
|
||||
use Egulias\EmailValidator\Exception\ExpectingATEXT;
|
||||
use Egulias\EmailValidator\Exception\NoLocalPart;
|
||||
use Egulias\EmailValidator\Parser\DomainPart;
|
||||
use Egulias\EmailValidator\Parser\LocalPart;
|
||||
use Egulias\EmailValidator\Warning\EmailTooLong;
|
||||
|
||||
/**
|
||||
* EmailParser
|
||||
*
|
||||
* @author Eduardo Gulias Davis <me@egulias.com>
|
||||
*/
|
||||
class EmailParser
|
||||
{
|
||||
const EMAIL_MAX_LENGTH = 254;
|
||||
|
||||
protected $warnings;
|
||||
protected $domainPart = '';
|
||||
protected $localPart = '';
|
||||
protected $lexer;
|
||||
protected $localPartParser;
|
||||
protected $domainPartParser;
|
||||
|
||||
public function __construct(EmailLexer $lexer)
|
||||
{
|
||||
$this->lexer = $lexer;
|
||||
$this->localPartParser = new LocalPart($this->lexer);
|
||||
$this->domainPartParser = new DomainPart($this->lexer);
|
||||
$this->warnings = new \SplObjectStorage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $str
|
||||
* @return array
|
||||
*/
|
||||
public function parse($str)
|
||||
{
|
||||
$this->lexer->setInput($str);
|
||||
|
||||
if (!$this->hasAtToken()) {
|
||||
throw new NoLocalPart();
|
||||
}
|
||||
|
||||
|
||||
$this->localPartParser->parse($str);
|
||||
$this->domainPartParser->parse($str);
|
||||
|
||||
$this->setParts($str);
|
||||
|
||||
if ($this->lexer->hasInvalidTokens()) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
|
||||
return array('local' => $this->localPart, 'domain' => $this->domainPart);
|
||||
}
|
||||
|
||||
public function getWarnings()
|
||||
{
|
||||
$localPartWarnings = $this->localPartParser->getWarnings();
|
||||
$domainPartWarnings = $this->domainPartParser->getWarnings();
|
||||
$this->warnings = array_merge($localPartWarnings, $domainPartWarnings);
|
||||
|
||||
$this->addLongEmailWarning($this->localPart, $this->domainPart);
|
||||
|
||||
return $this->warnings;
|
||||
}
|
||||
|
||||
public function getParsedDomainPart()
|
||||
{
|
||||
return $this->domainPart;
|
||||
}
|
||||
|
||||
protected function setParts($email)
|
||||
{
|
||||
$parts = explode('@', $email);
|
||||
$this->domainPart = $this->domainPartParser->getDomainPart();
|
||||
$this->localPart = $parts[0];
|
||||
}
|
||||
|
||||
protected function hasAtToken()
|
||||
{
|
||||
$this->lexer->moveNext();
|
||||
$this->lexer->moveNext();
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_AT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $localPart
|
||||
* @param string $parsedDomainPart
|
||||
*/
|
||||
protected function addLongEmailWarning($localPart, $parsedDomainPart)
|
||||
{
|
||||
if (strlen($localPart . '@' . $parsedDomainPart) > self::EMAIL_MAX_LENGTH) {
|
||||
$this->warnings[EmailTooLong::CODE] = new EmailTooLong();
|
||||
}
|
||||
}
|
||||
}
|
||||
67
lib/composer/vendor/egulias/email-validator/EmailValidator/EmailValidator.php
vendored
Normal file
67
lib/composer/vendor/egulias/email-validator/EmailValidator/EmailValidator.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator;
|
||||
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
use Egulias\EmailValidator\Validation\EmailValidation;
|
||||
|
||||
class EmailValidator
|
||||
{
|
||||
/**
|
||||
* @var EmailLexer
|
||||
*/
|
||||
private $lexer;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $warnings;
|
||||
|
||||
/**
|
||||
* @var InvalidEmail
|
||||
*/
|
||||
protected $error;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->lexer = new EmailLexer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $email
|
||||
* @param EmailValidation $emailValidation
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid($email, EmailValidation $emailValidation)
|
||||
{
|
||||
$isValid = $emailValidation->isValid($email, $this->lexer);
|
||||
$this->warnings = $emailValidation->getWarnings();
|
||||
$this->error = $emailValidation->getError();
|
||||
|
||||
return $isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasWarnings()
|
||||
{
|
||||
return !empty($this->warnings);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getWarnings()
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InvalidEmail
|
||||
*/
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/AtextAfterCFWS.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/AtextAfterCFWS.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class AtextAfterCFWS extends InvalidEmail
|
||||
{
|
||||
const CODE = 133;
|
||||
const REASON = "ATEXT found after CFWS";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/CRLFAtTheEnd.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/CRLFAtTheEnd.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class CRLFAtTheEnd extends InvalidEmail
|
||||
{
|
||||
const CODE = 149;
|
||||
const REASON = "CRLF at the end";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/CRLFX2.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/CRLFX2.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class CRLFX2 extends InvalidEmail
|
||||
{
|
||||
const CODE = 148;
|
||||
const REASON = "Folding whitespace CR LF found twice";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/CRNoLF.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/CRNoLF.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class CRNoLF extends InvalidEmail
|
||||
{
|
||||
const CODE = 150;
|
||||
const REASON = "Missing LF after CR";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/CharNotAllowed.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/CharNotAllowed.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class CharNotAllowed extends InvalidEmail
|
||||
{
|
||||
const CODE = 201;
|
||||
const REASON = "Non allowed character in domain";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/CommaInDomain.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/CommaInDomain.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class CommaInDomain extends InvalidEmail
|
||||
{
|
||||
const CODE = 200;
|
||||
const REASON = "Comma ',' is not allowed in domain part";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/ConsecutiveAt.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/ConsecutiveAt.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class ConsecutiveAt extends InvalidEmail
|
||||
{
|
||||
const CODE = 128;
|
||||
const REASON = "Consecutive AT";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/ConsecutiveDot.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/ConsecutiveDot.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class ConsecutiveDot extends InvalidEmail
|
||||
{
|
||||
const CODE = 132;
|
||||
const REASON = "Consecutive DOT";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/DomainHyphened.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/DomainHyphened.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class DomainHyphened extends InvalidEmail
|
||||
{
|
||||
const CODE = 144;
|
||||
const REASON = "Hyphen found in domain";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/DotAtEnd.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/DotAtEnd.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class DotAtEnd extends InvalidEmail
|
||||
{
|
||||
const CODE = 142;
|
||||
const REASON = "Dot at the end";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/DotAtStart.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/DotAtStart.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class DotAtStart extends InvalidEmail
|
||||
{
|
||||
const CODE = 141;
|
||||
const REASON = "Found DOT at start";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/ExpectingAT.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/ExpectingAT.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class ExpectingAT extends InvalidEmail
|
||||
{
|
||||
const CODE = 202;
|
||||
const REASON = "Expecting AT '@' ";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/ExpectingATEXT.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/ExpectingATEXT.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class ExpectingATEXT extends InvalidEmail
|
||||
{
|
||||
const CODE = 137;
|
||||
const REASON = "Expecting ATEXT";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/ExpectingCTEXT.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/ExpectingCTEXT.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class ExpectingCTEXT extends InvalidEmail
|
||||
{
|
||||
const CODE = 139;
|
||||
const REASON = "Expecting CTEXT";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/ExpectingDTEXT.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/ExpectingDTEXT.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class ExpectingDTEXT extends InvalidEmail
|
||||
{
|
||||
const CODE = 129;
|
||||
const REASON = "Expected DTEXT";
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class ExpectingDomainLiteralClose extends InvalidEmail
|
||||
{
|
||||
const CODE = 137;
|
||||
const REASON = "Closing bracket ']' for domain literal not found";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class ExpectedQPair extends InvalidEmail
|
||||
{
|
||||
const CODE = 136;
|
||||
const REASON = "Expecting QPAIR";
|
||||
}
|
||||
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/InvalidEmail.php
vendored
Normal file
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/InvalidEmail.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
abstract class InvalidEmail extends \InvalidArgumentException
|
||||
{
|
||||
const REASON = "Invalid email";
|
||||
const CODE = 0;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(static::REASON, static::CODE);
|
||||
}
|
||||
}
|
||||
11
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php
vendored
Normal file
11
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
|
||||
class NoDNSRecord extends InvalidEmail
|
||||
{
|
||||
const CODE = 5;
|
||||
const REASON = 'No MX or A DSN record was found for this email';
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/NoDomainPart.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/NoDomainPart.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class NoDomainPart extends InvalidEmail
|
||||
{
|
||||
const CODE = 131;
|
||||
const REASON = "No Domain part";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/NoLocalPart.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/NoLocalPart.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class NoLocalPart extends InvalidEmail
|
||||
{
|
||||
const CODE = 130;
|
||||
const REASON = "No local part";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/UnclosedComment.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/UnclosedComment.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class UnclosedComment extends InvalidEmail
|
||||
{
|
||||
const CODE = 146;
|
||||
const REASON = "No colosing comment token found";
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class UnclosedQuotedString extends InvalidEmail
|
||||
{
|
||||
const CODE = 145;
|
||||
const REASON = "Unclosed quoted string";
|
||||
}
|
||||
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/UnopenedComment.php
vendored
Normal file
9
lib/composer/vendor/egulias/email-validator/EmailValidator/Exception/UnopenedComment.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Exception;
|
||||
|
||||
class UnopenedComment extends InvalidEmail
|
||||
{
|
||||
const CODE = 152;
|
||||
const REASON = "No opening comment token found";
|
||||
}
|
||||
368
lib/composer/vendor/egulias/email-validator/EmailValidator/Parser/DomainPart.php
vendored
Normal file
368
lib/composer/vendor/egulias/email-validator/EmailValidator/Parser/DomainPart.php
vendored
Normal file
@@ -0,0 +1,368 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Parser;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\CharNotAllowed;
|
||||
use Egulias\EmailValidator\Exception\CommaInDomain;
|
||||
use Egulias\EmailValidator\Exception\ConsecutiveAt;
|
||||
use Egulias\EmailValidator\Exception\CRLFAtTheEnd;
|
||||
use Egulias\EmailValidator\Exception\CRNoLF;
|
||||
use Egulias\EmailValidator\Exception\DomainHyphened;
|
||||
use Egulias\EmailValidator\Exception\DotAtEnd;
|
||||
use Egulias\EmailValidator\Exception\DotAtStart;
|
||||
use Egulias\EmailValidator\Exception\ExpectingATEXT;
|
||||
use Egulias\EmailValidator\Exception\ExpectingDomainLiteralClose;
|
||||
use Egulias\EmailValidator\Exception\ExpectingDTEXT;
|
||||
use Egulias\EmailValidator\Exception\NoDomainPart;
|
||||
use Egulias\EmailValidator\Exception\UnopenedComment;
|
||||
use Egulias\EmailValidator\Warning\AddressLiteral;
|
||||
use Egulias\EmailValidator\Warning\CFWSWithFWS;
|
||||
use Egulias\EmailValidator\Warning\DeprecatedComment;
|
||||
use Egulias\EmailValidator\Warning\DomainLiteral;
|
||||
use Egulias\EmailValidator\Warning\DomainTooLong;
|
||||
use Egulias\EmailValidator\Warning\IPV6BadChar;
|
||||
use Egulias\EmailValidator\Warning\IPV6ColonEnd;
|
||||
use Egulias\EmailValidator\Warning\IPV6ColonStart;
|
||||
use Egulias\EmailValidator\Warning\IPV6Deprecated;
|
||||
use Egulias\EmailValidator\Warning\IPV6DoubleColon;
|
||||
use Egulias\EmailValidator\Warning\IPV6GroupCount;
|
||||
use Egulias\EmailValidator\Warning\IPV6MaxGroups;
|
||||
use Egulias\EmailValidator\Warning\LabelTooLong;
|
||||
use Egulias\EmailValidator\Warning\ObsoleteDTEXT;
|
||||
use Egulias\EmailValidator\Warning\TLD;
|
||||
|
||||
class DomainPart extends Parser
|
||||
{
|
||||
const DOMAIN_MAX_LENGTH = 254;
|
||||
protected $domainPart = '';
|
||||
|
||||
public function parse($domainPart)
|
||||
{
|
||||
$this->lexer->moveNext();
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT) {
|
||||
throw new DotAtStart();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_EMPTY) {
|
||||
throw new NoDomainPart();
|
||||
}
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) {
|
||||
throw new DomainHyphened();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
||||
$this->warnings[DeprecatedComment::CODE] = new DeprecatedComment();
|
||||
$this->parseDomainComments();
|
||||
}
|
||||
|
||||
$domain = $this->doParseDomainPart();
|
||||
|
||||
$prev = $this->lexer->getPrevious();
|
||||
$length = strlen($domain);
|
||||
|
||||
if ($prev['type'] === EmailLexer::S_DOT) {
|
||||
throw new DotAtEnd();
|
||||
}
|
||||
if ($prev['type'] === EmailLexer::S_HYPHEN) {
|
||||
throw new DomainHyphened();
|
||||
}
|
||||
if ($length > self::DOMAIN_MAX_LENGTH) {
|
||||
$this->warnings[DomainTooLong::CODE] = new DomainTooLong();
|
||||
}
|
||||
if ($prev['type'] === EmailLexer::S_CR) {
|
||||
throw new CRLFAtTheEnd();
|
||||
}
|
||||
$this->domainPart = $domain;
|
||||
}
|
||||
|
||||
public function getDomainPart()
|
||||
{
|
||||
return $this->domainPart;
|
||||
}
|
||||
|
||||
public function checkIPV6Tag($addressLiteral, $maxGroups = 8)
|
||||
{
|
||||
$prev = $this->lexer->getPrevious();
|
||||
if ($prev['type'] === EmailLexer::S_COLON) {
|
||||
$this->warnings[IPV6ColonEnd::CODE] = new IPV6ColonEnd();
|
||||
}
|
||||
|
||||
$IPv6 = substr($addressLiteral, 5);
|
||||
//Daniel Marschall's new IPv6 testing strategy
|
||||
$matchesIP = explode(':', $IPv6);
|
||||
$groupCount = count($matchesIP);
|
||||
$colons = strpos($IPv6, '::');
|
||||
|
||||
if (count(preg_grep('/^[0-9A-Fa-f]{0,4}$/', $matchesIP, PREG_GREP_INVERT)) !== 0) {
|
||||
$this->warnings[IPV6BadChar::CODE] = new IPV6BadChar();
|
||||
}
|
||||
|
||||
if ($colons === false) {
|
||||
// We need exactly the right number of groups
|
||||
if ($groupCount !== $maxGroups) {
|
||||
$this->warnings[IPV6GroupCount::CODE] = new IPV6GroupCount();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ($colons !== strrpos($IPv6, '::')) {
|
||||
$this->warnings[IPV6DoubleColon::CODE] = new IPV6DoubleColon();
|
||||
return;
|
||||
}
|
||||
|
||||
if ($colons === 0 || $colons === (strlen($IPv6) - 2)) {
|
||||
// RFC 4291 allows :: at the start or end of an address
|
||||
//with 7 other groups in addition
|
||||
++$maxGroups;
|
||||
}
|
||||
|
||||
if ($groupCount > $maxGroups) {
|
||||
$this->warnings[IPV6MaxGroups::CODE] = new IPV6MaxGroups();
|
||||
} elseif ($groupCount === $maxGroups) {
|
||||
$this->warnings[IPV6Deprecated::CODE] = new IPV6Deprecated();
|
||||
}
|
||||
}
|
||||
|
||||
protected function doParseDomainPart()
|
||||
{
|
||||
$domain = '';
|
||||
$openedParenthesis = 0;
|
||||
do {
|
||||
$prev = $this->lexer->getPrevious();
|
||||
|
||||
$this->checkNotAllowedChars($this->lexer->token);
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
||||
$this->parseComments();
|
||||
$openedParenthesis += $this->getOpenedParenthesis();
|
||||
$this->lexer->moveNext();
|
||||
$tmpPrev = $this->lexer->getPrevious();
|
||||
if ($tmpPrev['type'] === EmailLexer::S_CLOSEPARENTHESIS) {
|
||||
$openedParenthesis--;
|
||||
}
|
||||
}
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) {
|
||||
if ($openedParenthesis === 0) {
|
||||
throw new UnopenedComment();
|
||||
} else {
|
||||
$openedParenthesis--;
|
||||
}
|
||||
}
|
||||
|
||||
$this->checkConsecutiveDots();
|
||||
$this->checkDomainPartExceptions($prev);
|
||||
|
||||
if ($this->hasBrackets()) {
|
||||
$this->parseDomainLiteral();
|
||||
}
|
||||
|
||||
$this->checkLabelLength($prev);
|
||||
|
||||
if ($this->isFWS()) {
|
||||
$this->parseFWS();
|
||||
}
|
||||
|
||||
$domain .= $this->lexer->token['value'];
|
||||
$this->lexer->moveNext();
|
||||
} while ($this->lexer->token);
|
||||
|
||||
return $domain;
|
||||
}
|
||||
|
||||
private function checkNotAllowedChars($token)
|
||||
{
|
||||
$notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true];
|
||||
if (isset($notAllowed[$token['type']])) {
|
||||
throw new CharNotAllowed();
|
||||
}
|
||||
}
|
||||
|
||||
protected function parseDomainLiteral()
|
||||
{
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_COLON)) {
|
||||
$this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart();
|
||||
}
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_IPV6TAG)) {
|
||||
$lexer = clone $this->lexer;
|
||||
$lexer->moveNext();
|
||||
if ($lexer->isNextToken(EmailLexer::S_DOUBLECOLON)) {
|
||||
$this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->doParseDomainLiteral();
|
||||
}
|
||||
|
||||
protected function doParseDomainLiteral()
|
||||
{
|
||||
$IPv6TAG = false;
|
||||
$addressLiteral = '';
|
||||
do {
|
||||
if ($this->lexer->token['type'] === EmailLexer::C_NUL) {
|
||||
throw new ExpectingDTEXT();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::INVALID ||
|
||||
$this->lexer->token['type'] === EmailLexer::C_DEL ||
|
||||
$this->lexer->token['type'] === EmailLexer::S_LF
|
||||
) {
|
||||
$this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT();
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextTokenAny(array(EmailLexer::S_OPENQBRACKET, EmailLexer::S_OPENBRACKET))) {
|
||||
throw new ExpectingDTEXT();
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextTokenAny(
|
||||
array(EmailLexer::S_HTAB, EmailLexer::S_SP, $this->lexer->token['type'] === EmailLexer::CRLF)
|
||||
)) {
|
||||
$this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();
|
||||
$this->parseFWS();
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_CR)) {
|
||||
throw new CRNoLF();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) {
|
||||
$this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT();
|
||||
$addressLiteral .= $this->lexer->token['value'];
|
||||
$this->lexer->moveNext();
|
||||
$this->validateQuotedPair();
|
||||
}
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_IPV6TAG) {
|
||||
$IPv6TAG = true;
|
||||
}
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_CLOSEQBRACKET) {
|
||||
break;
|
||||
}
|
||||
|
||||
$addressLiteral .= $this->lexer->token['value'];
|
||||
|
||||
} while ($this->lexer->moveNext());
|
||||
|
||||
$addressLiteral = str_replace('[', '', $addressLiteral);
|
||||
$addressLiteral = $this->checkIPV4Tag($addressLiteral);
|
||||
|
||||
if (false === $addressLiteral) {
|
||||
return $addressLiteral;
|
||||
}
|
||||
|
||||
if (!$IPv6TAG) {
|
||||
$this->warnings[DomainLiteral::CODE] = new DomainLiteral();
|
||||
return $addressLiteral;
|
||||
}
|
||||
|
||||
$this->warnings[AddressLiteral::CODE] = new AddressLiteral();
|
||||
|
||||
$this->checkIPV6Tag($addressLiteral);
|
||||
|
||||
return $addressLiteral;
|
||||
}
|
||||
|
||||
protected function checkIPV4Tag($addressLiteral)
|
||||
{
|
||||
$matchesIP = array();
|
||||
|
||||
// Extract IPv4 part from the end of the address-literal (if there is one)
|
||||
if (preg_match(
|
||||
'/\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/',
|
||||
$addressLiteral,
|
||||
$matchesIP
|
||||
) > 0
|
||||
) {
|
||||
$index = strrpos($addressLiteral, $matchesIP[0]);
|
||||
if ($index === 0) {
|
||||
$this->warnings[AddressLiteral::CODE] = new AddressLiteral();
|
||||
return false;
|
||||
}
|
||||
// Convert IPv4 part to IPv6 format for further testing
|
||||
$addressLiteral = substr($addressLiteral, 0, $index) . '0:0';
|
||||
}
|
||||
|
||||
return $addressLiteral;
|
||||
}
|
||||
|
||||
protected function checkDomainPartExceptions($prev)
|
||||
{
|
||||
$invalidDomainTokens = array(
|
||||
EmailLexer::S_DQUOTE => true,
|
||||
EmailLexer::S_SEMICOLON => true,
|
||||
EmailLexer::S_GREATERTHAN => true,
|
||||
EmailLexer::S_LOWERTHAN => true,
|
||||
);
|
||||
|
||||
if (isset($invalidDomainTokens[$this->lexer->token['type']])) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_COMMA) {
|
||||
throw new CommaInDomain();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_AT) {
|
||||
throw new ConsecutiveAt();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENQBRACKET && $prev['type'] !== EmailLexer::S_AT) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
||||
throw new DomainHyphened();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH
|
||||
&& $this->lexer->isNextToken(EmailLexer::GENERIC)) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
}
|
||||
|
||||
protected function hasBrackets()
|
||||
{
|
||||
if ($this->lexer->token['type'] !== EmailLexer::S_OPENBRACKET) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->lexer->find(EmailLexer::S_CLOSEBRACKET);
|
||||
} catch (\RuntimeException $e) {
|
||||
throw new ExpectingDomainLiteralClose();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function checkLabelLength($prev)
|
||||
{
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT &&
|
||||
$prev['type'] === EmailLexer::GENERIC &&
|
||||
strlen($prev['value']) > 63
|
||||
) {
|
||||
$this->warnings[LabelTooLong::CODE] = new LabelTooLong();
|
||||
}
|
||||
}
|
||||
|
||||
protected function parseDomainComments()
|
||||
{
|
||||
$this->isUnclosedComment();
|
||||
while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) {
|
||||
$this->warnEscaping();
|
||||
$this->lexer->moveNext();
|
||||
}
|
||||
|
||||
$this->lexer->moveNext();
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
}
|
||||
|
||||
protected function addTLDWarnings()
|
||||
{
|
||||
if ($this->warnings[DomainLiteral::CODE]) {
|
||||
$this->warnings[TLD::CODE] = new TLD();
|
||||
}
|
||||
}
|
||||
}
|
||||
138
lib/composer/vendor/egulias/email-validator/EmailValidator/Parser/LocalPart.php
vendored
Normal file
138
lib/composer/vendor/egulias/email-validator/EmailValidator/Parser/LocalPart.php
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Parser;
|
||||
|
||||
use Egulias\EmailValidator\Exception\DotAtEnd;
|
||||
use Egulias\EmailValidator\Exception\DotAtStart;
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\Exception\ExpectingAT;
|
||||
use Egulias\EmailValidator\Exception\ExpectingATEXT;
|
||||
use Egulias\EmailValidator\Exception\UnclosedQuotedString;
|
||||
use Egulias\EmailValidator\Exception\UnopenedComment;
|
||||
use Egulias\EmailValidator\Warning\CFWSWithFWS;
|
||||
use Egulias\EmailValidator\Warning\LocalTooLong;
|
||||
|
||||
class LocalPart extends Parser
|
||||
{
|
||||
public function parse($localPart)
|
||||
{
|
||||
$parseDQuote = true;
|
||||
$closingQuote = false;
|
||||
$openedParenthesis = 0;
|
||||
|
||||
while ($this->lexer->token['type'] !== EmailLexer::S_AT && $this->lexer->token) {
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT && !$this->lexer->getPrevious()) {
|
||||
throw new DotAtStart();
|
||||
}
|
||||
|
||||
$closingQuote = $this->checkDQUOTE($closingQuote);
|
||||
if ($closingQuote && $parseDQuote) {
|
||||
$parseDQuote = $this->parseDoubleQuote();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
|
||||
$this->parseComments();
|
||||
$openedParenthesis += $this->getOpenedParenthesis();
|
||||
}
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) {
|
||||
if ($openedParenthesis === 0) {
|
||||
throw new UnopenedComment();
|
||||
} else {
|
||||
$openedParenthesis--;
|
||||
}
|
||||
}
|
||||
|
||||
$this->checkConsecutiveDots();
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT &&
|
||||
$this->lexer->isNextToken(EmailLexer::S_AT)
|
||||
) {
|
||||
throw new DotAtEnd();
|
||||
}
|
||||
|
||||
$this->warnEscaping();
|
||||
$this->isInvalidToken($this->lexer->token, $closingQuote);
|
||||
|
||||
if ($this->isFWS()) {
|
||||
$this->parseFWS();
|
||||
}
|
||||
|
||||
$this->lexer->moveNext();
|
||||
}
|
||||
|
||||
$prev = $this->lexer->getPrevious();
|
||||
if (strlen($prev['value']) > LocalTooLong::LOCAL_PART_LENGTH) {
|
||||
$this->warnings[LocalTooLong::CODE] = new LocalTooLong();
|
||||
}
|
||||
}
|
||||
|
||||
protected function parseDoubleQuote()
|
||||
{
|
||||
$parseAgain = true;
|
||||
$special = array(
|
||||
EmailLexer::S_CR => true,
|
||||
EmailLexer::S_HTAB => true,
|
||||
EmailLexer::S_LF => true
|
||||
);
|
||||
|
||||
$invalid = array(
|
||||
EmailLexer::C_NUL => true,
|
||||
EmailLexer::S_HTAB => true,
|
||||
EmailLexer::S_CR => true,
|
||||
EmailLexer::S_LF => true
|
||||
);
|
||||
$setSpecialsWarning = true;
|
||||
|
||||
$this->lexer->moveNext();
|
||||
|
||||
while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && $this->lexer->token) {
|
||||
$parseAgain = false;
|
||||
if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) {
|
||||
$this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();
|
||||
$setSpecialsWarning = false;
|
||||
}
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH && $this->lexer->isNextToken(EmailLexer::S_DQUOTE)) {
|
||||
$this->lexer->moveNext();
|
||||
}
|
||||
|
||||
$this->lexer->moveNext();
|
||||
|
||||
if (!$this->escaped() && isset($invalid[$this->lexer->token['type']])) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
}
|
||||
|
||||
$prev = $this->lexer->getPrevious();
|
||||
|
||||
if ($prev['type'] === EmailLexer::S_BACKSLASH) {
|
||||
if (!$this->checkDQUOTE(false)) {
|
||||
throw new UnclosedQuotedString();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->lexer->isNextToken(EmailLexer::S_AT) && $prev['type'] !== EmailLexer::S_BACKSLASH) {
|
||||
throw new ExpectingAT();
|
||||
}
|
||||
|
||||
return $parseAgain;
|
||||
}
|
||||
|
||||
protected function isInvalidToken($token, $closingQuote)
|
||||
{
|
||||
$forbidden = array(
|
||||
EmailLexer::S_COMMA,
|
||||
EmailLexer::S_CLOSEBRACKET,
|
||||
EmailLexer::S_OPENBRACKET,
|
||||
EmailLexer::S_GREATERTHAN,
|
||||
EmailLexer::S_LOWERTHAN,
|
||||
EmailLexer::S_COLON,
|
||||
EmailLexer::S_SEMICOLON,
|
||||
EmailLexer::INVALID
|
||||
);
|
||||
|
||||
if (in_array($token['type'], $forbidden) && !$closingQuote) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
}
|
||||
}
|
||||
215
lib/composer/vendor/egulias/email-validator/EmailValidator/Parser/Parser.php
vendored
Normal file
215
lib/composer/vendor/egulias/email-validator/EmailValidator/Parser/Parser.php
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Parser;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\AtextAfterCFWS;
|
||||
use Egulias\EmailValidator\Exception\ConsecutiveDot;
|
||||
use Egulias\EmailValidator\Exception\CRLFAtTheEnd;
|
||||
use Egulias\EmailValidator\Exception\CRLFX2;
|
||||
use Egulias\EmailValidator\Exception\CRNoLF;
|
||||
use Egulias\EmailValidator\Exception\ExpectedQPair;
|
||||
use Egulias\EmailValidator\Exception\ExpectingATEXT;
|
||||
use Egulias\EmailValidator\Exception\ExpectingCTEXT;
|
||||
use Egulias\EmailValidator\Exception\UnclosedComment;
|
||||
use Egulias\EmailValidator\Exception\UnclosedQuotedString;
|
||||
use Egulias\EmailValidator\Warning\CFWSNearAt;
|
||||
use Egulias\EmailValidator\Warning\CFWSWithFWS;
|
||||
use Egulias\EmailValidator\Warning\Comment;
|
||||
use Egulias\EmailValidator\Warning\QuotedPart;
|
||||
use Egulias\EmailValidator\Warning\QuotedString;
|
||||
|
||||
abstract class Parser
|
||||
{
|
||||
protected $warnings = [];
|
||||
protected $lexer;
|
||||
protected $openedParenthesis = 0;
|
||||
|
||||
public function __construct(EmailLexer $lexer)
|
||||
{
|
||||
$this->lexer = $lexer;
|
||||
}
|
||||
|
||||
public function getWarnings()
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
|
||||
abstract public function parse($str);
|
||||
|
||||
/** @return int */
|
||||
public function getOpenedParenthesis()
|
||||
{
|
||||
return $this->openedParenthesis;
|
||||
}
|
||||
|
||||
/**
|
||||
* validateQuotedPair
|
||||
*/
|
||||
protected function validateQuotedPair()
|
||||
{
|
||||
if (!($this->lexer->token['type'] === EmailLexer::INVALID
|
||||
|| $this->lexer->token['type'] === EmailLexer::C_DEL)) {
|
||||
throw new ExpectedQPair();
|
||||
}
|
||||
|
||||
$this->warnings[QuotedPart::CODE] =
|
||||
new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']);
|
||||
}
|
||||
|
||||
protected function parseComments()
|
||||
{
|
||||
$this->openedParenthesis = 1;
|
||||
$this->isUnclosedComment();
|
||||
$this->warnings[Comment::CODE] = new Comment();
|
||||
while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) {
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_OPENPARENTHESIS)) {
|
||||
$this->openedParenthesis++;
|
||||
}
|
||||
$this->warnEscaping();
|
||||
$this->lexer->moveNext();
|
||||
}
|
||||
|
||||
$this->lexer->moveNext();
|
||||
if ($this->lexer->isNextTokenAny(array(EmailLexer::GENERIC, EmailLexer::S_EMPTY))) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_AT)) {
|
||||
$this->warnings[CFWSNearAt::CODE] = new CFWSNearAt();
|
||||
}
|
||||
}
|
||||
|
||||
protected function isUnclosedComment()
|
||||
{
|
||||
try {
|
||||
$this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS);
|
||||
return true;
|
||||
} catch (\RuntimeException $e) {
|
||||
throw new UnclosedComment();
|
||||
}
|
||||
}
|
||||
|
||||
protected function parseFWS()
|
||||
{
|
||||
$previous = $this->lexer->getPrevious();
|
||||
|
||||
$this->checkCRLFInFWS();
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_CR) {
|
||||
throw new CRNoLF();
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] !== EmailLexer::S_AT) {
|
||||
throw new AtextAfterCFWS();
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_LF || $this->lexer->token['type'] === EmailLexer::C_NUL) {
|
||||
throw new ExpectingCTEXT();
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type'] === EmailLexer::S_AT) {
|
||||
$this->warnings[CFWSNearAt::CODE] = new CFWSNearAt();
|
||||
} else {
|
||||
$this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS();
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkConsecutiveDots()
|
||||
{
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) {
|
||||
throw new ConsecutiveDot();
|
||||
}
|
||||
}
|
||||
|
||||
protected function isFWS()
|
||||
{
|
||||
if ($this->escaped()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->lexer->token['type'] === EmailLexer::S_SP ||
|
||||
$this->lexer->token['type'] === EmailLexer::S_HTAB ||
|
||||
$this->lexer->token['type'] === EmailLexer::S_CR ||
|
||||
$this->lexer->token['type'] === EmailLexer::S_LF ||
|
||||
$this->lexer->token['type'] === EmailLexer::CRLF
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function escaped()
|
||||
{
|
||||
$previous = $this->lexer->getPrevious();
|
||||
|
||||
if ($previous['type'] === EmailLexer::S_BACKSLASH
|
||||
&&
|
||||
$this->lexer->token['type'] !== EmailLexer::GENERIC
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function warnEscaping()
|
||||
{
|
||||
if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->lexer->isNextToken(EmailLexer::GENERIC)) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
|
||||
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->warnings[QuotedPart::CODE] =
|
||||
new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
protected function checkDQUOTE($hasClosingQuote)
|
||||
{
|
||||
if ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE) {
|
||||
return $hasClosingQuote;
|
||||
}
|
||||
if ($hasClosingQuote) {
|
||||
return $hasClosingQuote;
|
||||
}
|
||||
$previous = $this->lexer->getPrevious();
|
||||
if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] === EmailLexer::GENERIC) {
|
||||
throw new ExpectingATEXT();
|
||||
}
|
||||
|
||||
try {
|
||||
$this->lexer->find(EmailLexer::S_DQUOTE);
|
||||
$hasClosingQuote = true;
|
||||
} catch (\Exception $e) {
|
||||
throw new UnclosedQuotedString();
|
||||
}
|
||||
$this->warnings[QuotedString::CODE] = new QuotedString($previous['value'], $this->lexer->token['value']);
|
||||
|
||||
return $hasClosingQuote;
|
||||
}
|
||||
|
||||
protected function checkCRLFInFWS()
|
||||
{
|
||||
if ($this->lexer->token['type'] !== EmailLexer::CRLF) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) {
|
||||
throw new CRLFX2();
|
||||
}
|
||||
|
||||
if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) {
|
||||
throw new CRLFAtTheEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
61
lib/composer/vendor/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php
vendored
Normal file
61
lib/composer/vendor/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
use Egulias\EmailValidator\Warning\NoDNSMXRecord;
|
||||
use Egulias\EmailValidator\Exception\NoDNSRecord;
|
||||
|
||||
class DNSCheckValidation implements EmailValidation
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $warnings = [];
|
||||
|
||||
/**
|
||||
* @var InvalidEmail
|
||||
*/
|
||||
private $error;
|
||||
|
||||
public function isValid($email, EmailLexer $emailLexer)
|
||||
{
|
||||
// use the input to check DNS if we cannot extract something similar to a domain
|
||||
$host = $email;
|
||||
|
||||
// Arguable pattern to extract the domain. Not aiming to validate the domain nor the email
|
||||
if (false !== $lastAtPos = strrpos($email, '@')) {
|
||||
$host = substr($email, $lastAtPos + 1);
|
||||
}
|
||||
|
||||
return $this->checkDNS($host);
|
||||
}
|
||||
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function getWarnings()
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
|
||||
protected function checkDNS($host)
|
||||
{
|
||||
$host = rtrim($host, '.') . '.';
|
||||
|
||||
$Aresult = true;
|
||||
$MXresult = checkdnsrr($host, 'MX');
|
||||
|
||||
if (!$MXresult) {
|
||||
$this->warnings[NoDNSMXRecord::CODE] = new NoDNSMXRecord();
|
||||
$Aresult = checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA');
|
||||
if (!$Aresult) {
|
||||
$this->error = new NoDNSRecord();
|
||||
}
|
||||
}
|
||||
return $MXresult || $Aresult;
|
||||
}
|
||||
}
|
||||
34
lib/composer/vendor/egulias/email-validator/EmailValidator/Validation/EmailValidation.php
vendored
Normal file
34
lib/composer/vendor/egulias/email-validator/EmailValidator/Validation/EmailValidation.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
use Egulias\EmailValidator\Warning\Warning;
|
||||
|
||||
interface EmailValidation
|
||||
{
|
||||
/**
|
||||
* Returns true if the given email is valid.
|
||||
*
|
||||
* @param string $email The email you want to validate.
|
||||
* @param EmailLexer $emailLexer The email lexer.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid($email, EmailLexer $emailLexer);
|
||||
|
||||
/**
|
||||
* Returns the validation error.
|
||||
*
|
||||
* @return InvalidEmail|null
|
||||
*/
|
||||
public function getError();
|
||||
|
||||
/**
|
||||
* Returns the validation warnings.
|
||||
*
|
||||
* @return Warning[]
|
||||
*/
|
||||
public function getWarnings();
|
||||
}
|
||||
11
lib/composer/vendor/egulias/email-validator/EmailValidator/Validation/Error/RFCWarnings.php
vendored
Normal file
11
lib/composer/vendor/egulias/email-validator/EmailValidator/Validation/Error/RFCWarnings.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation\Error;
|
||||
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
|
||||
class RFCWarnings extends InvalidEmail
|
||||
{
|
||||
const CODE = 997;
|
||||
const REASON = 'Warnings were found.';
|
||||
}
|
||||
11
lib/composer/vendor/egulias/email-validator/EmailValidator/Validation/Error/SpoofEmail.php
vendored
Normal file
11
lib/composer/vendor/egulias/email-validator/EmailValidator/Validation/Error/SpoofEmail.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation\Error;
|
||||
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
|
||||
class SpoofEmail extends InvalidEmail
|
||||
{
|
||||
const CODE = 998;
|
||||
const REASON = "The email contains mixed UTF8 chars that makes it suspicious";
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation\Exception;
|
||||
|
||||
use Exception;
|
||||
|
||||
class EmptyValidationList extends \InvalidArgumentException
|
||||
{
|
||||
public function __construct($code = 0, Exception $previous = null)
|
||||
{
|
||||
parent::__construct("Empty validation list is not allowed", $code, $previous);
|
||||
}
|
||||
}
|
||||
26
lib/composer/vendor/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php
vendored
Normal file
26
lib/composer/vendor/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
|
||||
class MultipleErrors extends InvalidEmail
|
||||
{
|
||||
const CODE = 999;
|
||||
const REASON = "Accumulated errors for multiple validations";
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $errors = [];
|
||||
|
||||
public function __construct(array $errors)
|
||||
{
|
||||
$this->errors = $errors;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getErrors()
|
||||
{
|
||||
return $this->errors;
|
||||
}
|
||||
}
|
||||
110
lib/composer/vendor/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php
vendored
Normal file
110
lib/composer/vendor/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Validation\Exception\EmptyValidationList;
|
||||
|
||||
class MultipleValidationWithAnd implements EmailValidation
|
||||
{
|
||||
/**
|
||||
* If one of validations gets failure skips all succeeding validation.
|
||||
* This means MultipleErrors will only contain a single error which first found.
|
||||
*/
|
||||
const STOP_ON_ERROR = 0;
|
||||
|
||||
/**
|
||||
* All of validations will be invoked even if one of them got failure.
|
||||
* So MultipleErrors will contain all causes.
|
||||
*/
|
||||
const ALLOW_ALL_ERRORS = 1;
|
||||
|
||||
/**
|
||||
* @var EmailValidation[]
|
||||
*/
|
||||
private $validations = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $warnings = [];
|
||||
|
||||
/**
|
||||
* @var MultipleErrors
|
||||
*/
|
||||
private $error;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $mode;
|
||||
|
||||
/**
|
||||
* @param EmailValidation[] $validations The validations.
|
||||
* @param int $mode The validation mode (one of the constants).
|
||||
*/
|
||||
public function __construct(array $validations, $mode = self::ALLOW_ALL_ERRORS)
|
||||
{
|
||||
if (count($validations) == 0) {
|
||||
throw new EmptyValidationList();
|
||||
}
|
||||
|
||||
$this->validations = $validations;
|
||||
$this->mode = $mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isValid($email, EmailLexer $emailLexer)
|
||||
{
|
||||
$result = true;
|
||||
$errors = [];
|
||||
foreach ($this->validations as $validation) {
|
||||
$emailLexer->reset();
|
||||
$result = $result && $validation->isValid($email, $emailLexer);
|
||||
$this->warnings = array_merge($this->warnings, $validation->getWarnings());
|
||||
$errors = $this->addNewError($validation->getError(), $errors);
|
||||
|
||||
if ($this->shouldStop($result)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
$this->error = new MultipleErrors($errors);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function addNewError($possibleError, array $errors)
|
||||
{
|
||||
if (null !== $possibleError) {
|
||||
$errors[] = $possibleError;
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
private function shouldStop($result)
|
||||
{
|
||||
return !$result && $this->mode === self::STOP_ON_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getWarnings()
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
use Egulias\EmailValidator\Validation\Error\RFCWarnings;
|
||||
|
||||
class NoRFCWarningsValidation extends RFCValidation
|
||||
{
|
||||
/**
|
||||
* @var InvalidEmail
|
||||
*/
|
||||
private $error;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isValid($email, EmailLexer $emailLexer)
|
||||
{
|
||||
if (!parent::isValid($email, $emailLexer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($this->getWarnings())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->error = new RFCWarnings();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getError()
|
||||
{
|
||||
return $this->error ?: parent::getError();
|
||||
}
|
||||
}
|
||||
49
lib/composer/vendor/egulias/email-validator/EmailValidator/Validation/RFCValidation.php
vendored
Normal file
49
lib/composer/vendor/egulias/email-validator/EmailValidator/Validation/RFCValidation.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\EmailParser;
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
|
||||
class RFCValidation implements EmailValidation
|
||||
{
|
||||
/**
|
||||
* @var EmailParser
|
||||
*/
|
||||
private $parser;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $warnings = [];
|
||||
|
||||
/**
|
||||
* @var InvalidEmail
|
||||
*/
|
||||
private $error;
|
||||
|
||||
public function isValid($email, EmailLexer $emailLexer)
|
||||
{
|
||||
$this->parser = new EmailParser($emailLexer);
|
||||
try {
|
||||
$this->parser->parse((string)$email);
|
||||
} catch (InvalidEmail $invalid) {
|
||||
$this->error = $invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->warnings = $this->parser->getWarnings();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function getWarnings()
|
||||
{
|
||||
return $this->warnings;
|
||||
}
|
||||
}
|
||||
45
lib/composer/vendor/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php
vendored
Normal file
45
lib/composer/vendor/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Validation;
|
||||
|
||||
use Egulias\EmailValidator\EmailLexer;
|
||||
use Egulias\EmailValidator\Exception\InvalidEmail;
|
||||
use Egulias\EmailValidator\Validation\Error\SpoofEmail;
|
||||
use \Spoofchecker;
|
||||
|
||||
class SpoofCheckValidation implements EmailValidation
|
||||
{
|
||||
/**
|
||||
* @var InvalidEmail
|
||||
*/
|
||||
private $error;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (!class_exists(Spoofchecker::class)) {
|
||||
throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__));
|
||||
}
|
||||
}
|
||||
|
||||
public function isValid($email, EmailLexer $emailLexer)
|
||||
{
|
||||
$checker = new Spoofchecker();
|
||||
$checker->setChecks(Spoofchecker::SINGLE_SCRIPT);
|
||||
|
||||
if ($checker->isSuspicious($email)) {
|
||||
$this->error = new SpoofEmail();
|
||||
}
|
||||
|
||||
return $this->error === null;
|
||||
}
|
||||
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function getWarnings()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/AddressLiteral.php
vendored
Normal file
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/AddressLiteral.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class AddressLiteral extends Warning
|
||||
{
|
||||
const CODE = 12;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Address literal in domain part';
|
||||
$this->rfcNumber = 5321;
|
||||
}
|
||||
}
|
||||
13
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/CFWSNearAt.php
vendored
Normal file
13
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/CFWSNearAt.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class CFWSNearAt extends Warning
|
||||
{
|
||||
const CODE = 49;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = "Deprecated folding white space near @";
|
||||
}
|
||||
}
|
||||
13
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/CFWSWithFWS.php
vendored
Normal file
13
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/CFWSWithFWS.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class CFWSWithFWS extends Warning
|
||||
{
|
||||
const CODE = 18;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Folding whites space followed by folding white space';
|
||||
}
|
||||
}
|
||||
13
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/Comment.php
vendored
Normal file
13
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/Comment.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class Comment extends Warning
|
||||
{
|
||||
const CODE = 17;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = "Comments found in this email";
|
||||
}
|
||||
}
|
||||
13
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/DeprecatedComment.php
vendored
Normal file
13
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/DeprecatedComment.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class DeprecatedComment extends Warning
|
||||
{
|
||||
const CODE = 37;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Deprecated comments';
|
||||
}
|
||||
}
|
||||
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/DomainLiteral.php
vendored
Normal file
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/DomainLiteral.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class DomainLiteral extends Warning
|
||||
{
|
||||
const CODE = 70;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Domain Literal';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/DomainTooLong.php
vendored
Normal file
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/DomainTooLong.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class DomainTooLong extends Warning
|
||||
{
|
||||
const CODE = 255;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Domain is too long, exceeds 255 chars';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
15
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/EmailTooLong.php
vendored
Normal file
15
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/EmailTooLong.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
use Egulias\EmailValidator\EmailParser;
|
||||
|
||||
class EmailTooLong extends Warning
|
||||
{
|
||||
const CODE = 66;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Email is too long, exceeds ' . EmailParser::EMAIL_MAX_LENGTH;
|
||||
}
|
||||
}
|
||||
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/IPV6BadChar.php
vendored
Normal file
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/IPV6BadChar.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6BadChar extends Warning
|
||||
{
|
||||
const CODE = 74;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Bad char in IPV6 domain literal';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/IPV6ColonEnd.php
vendored
Normal file
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/IPV6ColonEnd.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6ColonEnd extends Warning
|
||||
{
|
||||
const CODE = 77;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = ':: found at the end of the domain literal';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/IPV6ColonStart.php
vendored
Normal file
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/IPV6ColonStart.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6ColonStart extends Warning
|
||||
{
|
||||
const CODE = 76;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = ':: found at the start of the domain literal';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/IPV6Deprecated.php
vendored
Normal file
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/IPV6Deprecated.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6Deprecated extends Warning
|
||||
{
|
||||
const CODE = 13;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Deprecated form of IPV6';
|
||||
$this->rfcNumber = 5321;
|
||||
}
|
||||
}
|
||||
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/IPV6DoubleColon.php
vendored
Normal file
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/IPV6DoubleColon.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6DoubleColon extends Warning
|
||||
{
|
||||
const CODE = 73;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Double colon found after IPV6 tag';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/IPV6GroupCount.php
vendored
Normal file
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/IPV6GroupCount.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6GroupCount extends Warning
|
||||
{
|
||||
const CODE = 72;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Group count is not IPV6 valid';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/IPV6MaxGroups.php
vendored
Normal file
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/IPV6MaxGroups.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class IPV6MaxGroups extends Warning
|
||||
{
|
||||
const CODE = 75;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Reached the maximum number of IPV6 groups allowed';
|
||||
$this->rfcNumber = 5321;
|
||||
}
|
||||
}
|
||||
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/LabelTooLong.php
vendored
Normal file
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/LabelTooLong.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class LabelTooLong extends Warning
|
||||
{
|
||||
const CODE = 63;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Label too long';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
15
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/LocalTooLong.php
vendored
Normal file
15
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/LocalTooLong.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class LocalTooLong extends Warning
|
||||
{
|
||||
const CODE = 64;
|
||||
const LOCAL_PART_LENGTH = 64;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'Local part is too long, exceeds 64 chars (octets)';
|
||||
$this->rfcNumber = 5322;
|
||||
}
|
||||
}
|
||||
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/NoDNSMXRecord.php
vendored
Normal file
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/NoDNSMXRecord.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class NoDNSMXRecord extends Warning
|
||||
{
|
||||
const CODE = 6;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = 'No MX DSN record was found for this email';
|
||||
$this->rfcNumber = 5321;
|
||||
}
|
||||
}
|
||||
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/ObsoleteDTEXT.php
vendored
Normal file
14
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/ObsoleteDTEXT.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class ObsoleteDTEXT extends Warning
|
||||
{
|
||||
const CODE = 71;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->rfcNumber = 5322;
|
||||
$this->message = 'Obsolete DTEXT in domain literal';
|
||||
}
|
||||
}
|
||||
13
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/QuotedPart.php
vendored
Normal file
13
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/QuotedPart.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class QuotedPart extends Warning
|
||||
{
|
||||
const CODE = 36;
|
||||
|
||||
public function __construct($prevToken, $postToken)
|
||||
{
|
||||
$this->message = "Deprecated Quoted String found between $prevToken and $postToken";
|
||||
}
|
||||
}
|
||||
13
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/QuotedString.php
vendored
Normal file
13
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/QuotedString.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class QuotedString extends Warning
|
||||
{
|
||||
const CODE = 11;
|
||||
|
||||
public function __construct($prevToken, $postToken)
|
||||
{
|
||||
$this->message = "Quoted String found between $prevToken and $postToken";
|
||||
}
|
||||
}
|
||||
13
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/TLD.php
vendored
Normal file
13
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/TLD.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
class TLD extends Warning
|
||||
{
|
||||
const CODE = 9;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->message = "RFC5321, TLD";
|
||||
}
|
||||
}
|
||||
30
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/Warning.php
vendored
Normal file
30
lib/composer/vendor/egulias/email-validator/EmailValidator/Warning/Warning.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Egulias\EmailValidator\Warning;
|
||||
|
||||
abstract class Warning
|
||||
{
|
||||
const CODE = 0;
|
||||
protected $message;
|
||||
protected $rfcNumber;
|
||||
|
||||
public function message()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
public function code()
|
||||
{
|
||||
return self::CODE;
|
||||
}
|
||||
|
||||
public function RFCNumber()
|
||||
{
|
||||
return $this->rfcNumber;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->message() . " rfc: " . $this->rfcNumber . "interal code: " . static::CODE;
|
||||
}
|
||||
}
|
||||
19
lib/composer/vendor/egulias/email-validator/LICENSE
vendored
Normal file
19
lib/composer/vendor/egulias/email-validator/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2013-2016 Eduardo Gulias Davis
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
79
lib/composer/vendor/egulias/email-validator/README.md
vendored
Normal file
79
lib/composer/vendor/egulias/email-validator/README.md
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
# EmailValidator
|
||||
[](https://travis-ci.org/egulias/EmailValidator) [](https://coveralls.io/r/egulias/EmailValidator?branch=master) [](https://scrutinizer-ci.com/g/egulias/EmailValidator/?branch=master) [](https://insight.sensiolabs.com/projects/22ba6692-9c02-42e5-a65d-1c5696bfffc6)
|
||||
=============================
|
||||
With the help of [PHPStorm](https://www.jetbrains.com/phpstorm/)
|
||||
|
||||
## Requirements ##
|
||||
|
||||
* [Composer](https://getcomposer.org) is required for installation
|
||||
* [Spoofchecking](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/SpoofCheckValidation.php) validation requires that your PHP system have the [PHP Internationalization Libraries](http://php.net/manual/en/book.intl.php) (also known as PHP Intl)
|
||||
|
||||
## Installation ##
|
||||
|
||||
Run the command below to install via Composer
|
||||
|
||||
```shell
|
||||
composer require egulias/email-validator "~2.1"
|
||||
```
|
||||
|
||||
## Getting Started ##
|
||||
`EmailValidator`requires you to decide which (or combination of them) validation/s strategy/ies you'd like to follow for each [validation](#available-validations).
|
||||
|
||||
A basic example with the RFC validation
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\Validation\RFCValidation;
|
||||
|
||||
$validator = new EmailValidator();
|
||||
$validator->isValid("example@example.com", new RFCValidation()); //true
|
||||
```
|
||||
|
||||
|
||||
### Available validations ###
|
||||
|
||||
1. [RFCValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/RFCValidation.php)
|
||||
2. [NoRFCWarningsValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/NoRFCWarningsValidation.php)
|
||||
3. [DNSCheckValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/DNSCheckValidation.php)
|
||||
4. [SpoofCheckValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/SpoofCheckValidation.php)
|
||||
5. [MultipleValidationWithAnd](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/MultipleValidationWithAnd.php)
|
||||
6. [Your own validation](#how-to-extend)
|
||||
|
||||
`MultipleValidationWithAnd`
|
||||
|
||||
It is a validation that operates over other validations performing a logical and (&&) over the result of each validation.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\Validation\DNSCheckValidation;
|
||||
use Egulias\EmailValidator\Validation\MultipleValidationWithAnd;
|
||||
use Egulias\EmailValidator\Validation\RFCValidation;
|
||||
|
||||
$validator = new EmailValidator();
|
||||
$multipleValidations = new MultipleValidationWithAnd([
|
||||
new RFCValidation(),
|
||||
new DNSCheckValidation()
|
||||
]);
|
||||
$validator->isValid("example@example.com", $multipleValidations); //true
|
||||
```
|
||||
|
||||
### How to extend ###
|
||||
|
||||
It's easy! You just need to extend [EmailValidation](https://github.com/egulias/EmailValidator/blob/master/EmailValidator/Validation/EmailValidation.php) and you can use your own validation.
|
||||
|
||||
|
||||
## Other Contributors ##
|
||||
(You can find current contributors [here](https://github.com/egulias/EmailValidator/graphs/contributors))
|
||||
|
||||
As this is a port from another library and work, here are other people related to the previous one:
|
||||
|
||||
* Ricard Clau [@ricardclau](http://github.com/ricardclau): Performance against PHP built-in filter_var
|
||||
* Josepf Bielawski [@stloyd](http://github.com/stloyd): For its first re-work of Dominic's lib
|
||||
* Dominic Sayers [@dominicsayers](http://github.com/dominicsayers): The original isemail function
|
||||
|
||||
## License ##
|
||||
Released under the MIT License attached with this code.
|
||||
|
||||
39
lib/composer/vendor/egulias/email-validator/composer.json
vendored
Normal file
39
lib/composer/vendor/egulias/email-validator/composer.json
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "egulias/email-validator",
|
||||
"description": "A library for validating emails against several RFCs",
|
||||
"homepage": "https://github.com/egulias/EmailValidator",
|
||||
"type": "Library",
|
||||
"keywords": ["email", "validation", "validator", "emailvalidation", "emailvalidator"],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{"name": "Eduardo Gulias Davis"}
|
||||
],
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/dominicsayers/isemail"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">= 5.5",
|
||||
"doctrine/lexer": "^1.0.1"
|
||||
},
|
||||
"require-dev" : {
|
||||
"satooshi/php-coveralls": "^1.0.1",
|
||||
"phpunit/phpunit": "^4.8.35",
|
||||
"dominicsayers/isemail": "dev-master"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Egulias\\EmailValidator\\": "EmailValidator"
|
||||
}
|
||||
}
|
||||
}
|
||||
1813
lib/composer/vendor/egulias/email-validator/composer.lock
generated
vendored
Normal file
1813
lib/composer/vendor/egulias/email-validator/composer.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
26
lib/composer/vendor/egulias/email-validator/phpunit.xml.dist
vendored
Normal file
26
lib/composer/vendor/egulias/email-validator/phpunit.xml.dist
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
bootstrap="vendor/autoload.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="EmailValidator Test Suite">
|
||||
<directory>./Tests/EmailValidator</directory>
|
||||
<exclude>./vendor/</exclude>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<blacklist>
|
||||
<directory>./vendor</directory>
|
||||
</blacklist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
9
lib/composer/vendor/swiftmailer/swiftmailer/.gitattributes
vendored
Normal file
9
lib/composer/vendor/swiftmailer/swiftmailer/.gitattributes
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
*.crt -crlf
|
||||
*.key -crlf
|
||||
*.srl -crlf
|
||||
*.pub -crlf
|
||||
*.priv -crlf
|
||||
*.txt -crlf
|
||||
|
||||
# ignore /notes in the git-generated distributed .zip archive
|
||||
/doc/notes export-ignore
|
||||
19
lib/composer/vendor/swiftmailer/swiftmailer/.github/ISSUE_TEMPLATE.md
vendored
Normal file
19
lib/composer/vendor/swiftmailer/swiftmailer/.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<!-- Please fill in this template according to your issue. -->
|
||||
|
||||
| Q | A
|
||||
| ------------------- | -----
|
||||
| Bug report? | yes/no
|
||||
| Feature request? | yes/no
|
||||
| RFC? | yes/no
|
||||
| How used? | Standalone/Symfony/3party
|
||||
| Swiftmailer version | x.y.z
|
||||
| PHP version | x.y.z
|
||||
|
||||
### Observed behaviour
|
||||
<!-- What does the code do? -->
|
||||
|
||||
### Expected behaviour
|
||||
<!-- What should the code do? -->
|
||||
|
||||
### Example
|
||||
<!-- Example to reproduce the issue. -->
|
||||
14
lib/composer/vendor/swiftmailer/swiftmailer/.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
14
lib/composer/vendor/swiftmailer/swiftmailer/.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<!-- Please fill in this template according to the PR you're about to submit. -->
|
||||
|
||||
| Q | A
|
||||
| ------------- | ---
|
||||
| Bug fix? | yes/no
|
||||
| New feature? | yes/no
|
||||
| Doc update? | yes/no
|
||||
| BC breaks? | yes/no
|
||||
| Deprecations? | yes/no
|
||||
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
|
||||
| License | MIT
|
||||
|
||||
|
||||
<!-- Replace this comment by the description of your issue. -->
|
||||
8
lib/composer/vendor/swiftmailer/swiftmailer/.gitignore
vendored
Normal file
8
lib/composer/vendor/swiftmailer/swiftmailer/.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/.php_cs.cache
|
||||
/.phpunit
|
||||
/build/*
|
||||
/composer.lock
|
||||
/phpunit.xml
|
||||
/tests/acceptance.conf.php
|
||||
/tests/smoke.conf.php
|
||||
/vendor/
|
||||
15
lib/composer/vendor/swiftmailer/swiftmailer/.php_cs.dist
vendored
Normal file
15
lib/composer/vendor/swiftmailer/swiftmailer/.php_cs.dist
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRules(array(
|
||||
'@Symfony' => true,
|
||||
'@Symfony:risky' => true,
|
||||
'array_syntax' => array('syntax' => 'long'),
|
||||
'no_unreachable_default_argument_value' => false,
|
||||
'braces' => array('allow_single_line_closure' => true),
|
||||
'heredoc_to_nowdoc' => false,
|
||||
'phpdoc_annotation_without_dot' => false,
|
||||
))
|
||||
->setRiskyAllowed(true)
|
||||
->setFinder(PhpCsFixer\Finder::create()->in(__DIR__))
|
||||
;
|
||||
24
lib/composer/vendor/swiftmailer/swiftmailer/.travis.yml
vendored
Normal file
24
lib/composer/vendor/swiftmailer/swiftmailer/.travis.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
language: php
|
||||
|
||||
sudo: false
|
||||
|
||||
before_script:
|
||||
- cp tests/acceptance.conf.php.default tests/acceptance.conf.php
|
||||
- cp tests/smoke.conf.php.default tests/smoke.conf.php
|
||||
- composer self-update
|
||||
- composer update --no-interaction --prefer-source
|
||||
- gem install mime-types -v 2.99.1
|
||||
- gem install mailcatcher
|
||||
- mailcatcher --smtp-port 4456
|
||||
|
||||
script: SYMFONY_PHPUNIT_VERSION=6.1 ./vendor/bin/simple-phpunit
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 7.0
|
||||
- php: 7.1
|
||||
fast_finish: true
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- .phpunit
|
||||
299
lib/composer/vendor/swiftmailer/swiftmailer/CHANGES
vendored
Normal file
299
lib/composer/vendor/swiftmailer/swiftmailer/CHANGES
vendored
Normal file
@@ -0,0 +1,299 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
6.0.2 (2017-09-30)
|
||||
------------------
|
||||
|
||||
* fixed DecoratorPlugin
|
||||
* removed usage of getmypid()
|
||||
|
||||
6.0.1 (2017-05-20)
|
||||
------------------
|
||||
|
||||
* fixed BC break that can be avoided easily
|
||||
|
||||
6.0.0 (2017-05-19)
|
||||
------------------
|
||||
|
||||
* added Swift_Transport::ping()
|
||||
* removed Swift_Mime_HeaderFactory, Swift_Mime_HeaderSet, Swift_Mime_Message, Swift_Mime_MimeEntity,
|
||||
and Swift_Mime_ParameterizedHeader interfaces
|
||||
* removed Swift_MailTransport and Swift_Transport_MailTransport
|
||||
* removed Swift_Encoding
|
||||
* removed the Swift_Transport_MailInvoker interface and Swift_Transport_SimpleMailInvoker class
|
||||
* removed the Swift_SignedMessage class
|
||||
* removed newInstance() methods everywhere
|
||||
* methods operating on Date header now use DateTimeImmutable object instead of Unix timestamp;
|
||||
Swift_Mime_Headers_DateHeader::getTimestamp()/setTimestamp() renamed to getDateTime()/setDateTime()
|
||||
* bumped minimum version to PHP 7.0
|
||||
* removed Swift_Validate and replaced by egulias/email-validator
|
||||
|
||||
5.4.9 (2017-XX-XX)
|
||||
------------------
|
||||
|
||||
* n/a
|
||||
|
||||
5.4.8 (2017-05-01)
|
||||
------------------
|
||||
|
||||
* fixed encoding inheritance in addPart()
|
||||
* fixed sorting MIME children when their types are equal
|
||||
|
||||
5.4.7 (2017-04-20)
|
||||
------------------
|
||||
|
||||
* fixed NTLMAuthenticator clobbering bcmath scale
|
||||
|
||||
5.4.6 (2017-02-13)
|
||||
------------------
|
||||
|
||||
* removed exceptions thrown in destructors as they lead to fatal errors
|
||||
* switched to use sha256 by default in DKIM as per the RFC
|
||||
* fixed an 'Undefined variable: pipes' PHP notice
|
||||
* fixed long To headers when using the mail transport
|
||||
* fixed NTLMAuthenticator when no domain is passed with the username
|
||||
* prevented fatal error during unserialization of a message
|
||||
* fixed a PHP warning when sending a message that has a length of a multiple of 8192
|
||||
|
||||
5.4.5 (2016-12-29)
|
||||
------------------
|
||||
|
||||
* SECURITY FIX: fixed CVE-2016-10074 by disallowing potentially unsafe shell characters
|
||||
|
||||
Prior to 5.4.5, the mail transport (Swift_Transport_MailTransport) was vulnerable to passing
|
||||
arbitrary shell arguments if the "From", "ReturnPath" or "Sender" header came
|
||||
from a non-trusted source, potentially allowing Remote Code Execution
|
||||
* deprecated the mail transport
|
||||
|
||||
5.4.4 (2016-11-23)
|
||||
------------------
|
||||
|
||||
* reverted escaping command-line args to mail (PHP mail() function already does it)
|
||||
|
||||
5.4.3 (2016-07-08)
|
||||
------------------
|
||||
|
||||
* fixed SimpleHeaderSet::has()/get() when the 0 index is removed
|
||||
* removed the need to have mcrypt installed
|
||||
* fixed broken MIME header encoding with quotes/colons and non-ascii chars
|
||||
* allowed mail transport send for messages without To header
|
||||
* fixed PHP 7 support
|
||||
|
||||
5.4.2 (2016-05-01)
|
||||
------------------
|
||||
|
||||
* fixed support for IPv6 sockets
|
||||
* added auto-retry when sending messages from the memory spool
|
||||
* fixed consecutive read calls in Swift_ByteStream_FileByteStream
|
||||
* added support for iso-8859-15 encoding
|
||||
* fixed PHP mail extra params on missing reversePath
|
||||
* added methods to set custom stream context options
|
||||
* fixed charset changes in QpContentEncoderProxy
|
||||
* added return-path header to the ignoredHeaders list of DKIMSigner
|
||||
* fixed crlf for subject using mail
|
||||
* fixed add soft line break only when necessary
|
||||
* fixed escaping command-line args to mail
|
||||
|
||||
5.4.1 (2015-06-06)
|
||||
------------------
|
||||
|
||||
* made Swiftmailer exceptions confirm to PHP base exception constructor signature
|
||||
* fixed MAIL FROM & RCPT TO headers to be RFC compliant
|
||||
|
||||
5.4.0 (2015-03-14)
|
||||
------------------
|
||||
|
||||
* added the possibility to add extra certs to PKCS#7 signature
|
||||
* fix base64 encoding with streams
|
||||
* added a new RESULT_SPOOLED status for SpoolTransport
|
||||
* fixed getBody() on attachments when called more than once
|
||||
* removed dots from generated filenames in filespool
|
||||
|
||||
5.3.1 (2014-12-05)
|
||||
------------------
|
||||
|
||||
* fixed cloning of messages with attachments
|
||||
|
||||
5.3.0 (2014-10-04)
|
||||
------------------
|
||||
|
||||
* fixed cloning when using signers
|
||||
* reverted removal of Swift_Encoding
|
||||
* drop support for PHP 5.2.x
|
||||
|
||||
5.2.2 (2014-09-20)
|
||||
------------------
|
||||
|
||||
* fixed Japanese support
|
||||
* fixed the memory spool when the message changes when in the pool
|
||||
* added support for cloning messages
|
||||
* fixed PHP warning in the redirect plugin
|
||||
* changed the way to and cc-ed email are sent to only use one transaction
|
||||
|
||||
5.2.1 (2014-06-13)
|
||||
------------------
|
||||
|
||||
* SECURITY FIX: fixed CLI escaping when using sendmail as a transport
|
||||
|
||||
Prior to 5.2.1, the sendmail transport (Swift_Transport_SendmailTransport)
|
||||
was vulnerable to an arbitrary shell execution if the "From" header came
|
||||
from a non-trusted source and no "Return-Path" is configured.
|
||||
|
||||
* fixed parameter in DKIMSigner
|
||||
* fixed compatibility with PHP < 5.4
|
||||
|
||||
5.2.0 (2014-05-08)
|
||||
------------------
|
||||
|
||||
* fixed Swift_ByteStream_FileByteStream::read() to match to the specification
|
||||
* fixed from-charset and to-charset arguments in mbstring_convert_encoding() usages
|
||||
* fixed infinite loop in StreamBuffer
|
||||
* fixed NullTransport to return the number of ignored emails instead of 0
|
||||
* Use phpunit and mockery for unit testing (realityking)
|
||||
|
||||
5.1.0 (2014-03-18)
|
||||
------------------
|
||||
|
||||
* fixed data writing to stream when sending large messages
|
||||
* added support for libopendkim (https://github.com/xdecock/php-opendkim)
|
||||
* merged SignedMessage and Message
|
||||
* added Gmail XOAuth2 authentication
|
||||
* updated the list of known mime types
|
||||
* added NTLM authentication
|
||||
|
||||
5.0.3 (2013-12-03)
|
||||
------------------
|
||||
|
||||
* fixed double-dot bug
|
||||
* fixed DKIM signer
|
||||
|
||||
5.0.2 (2013-08-30)
|
||||
------------------
|
||||
|
||||
* handled correct exception type while reading IoBuffer output
|
||||
|
||||
5.0.1 (2013-06-17)
|
||||
------------------
|
||||
|
||||
* changed the spool to only start the transport when a mail has to be sent
|
||||
* fixed compatibility with PHP 5.2
|
||||
* fixed LICENSE file
|
||||
|
||||
5.0.0 (2013-04-30)
|
||||
------------------
|
||||
|
||||
* changed the license from LGPL to MIT
|
||||
|
||||
4.3.1 (2013-04-11)
|
||||
------------------
|
||||
|
||||
* removed usage of the native QP encoder when the charset is not UTF-8
|
||||
* fixed usage of uniqid to avoid collisions
|
||||
* made a performance improvement when tokenizing large headers
|
||||
* fixed usage of the PHP native QP encoder on PHP 5.4.7+
|
||||
|
||||
4.3.0 (2013-01-08)
|
||||
------------------
|
||||
|
||||
* made the temporary directory configurable via the TMPDIR env variable
|
||||
* added S/MIME signer and encryption support
|
||||
|
||||
4.2.2 (2012-10-25)
|
||||
------------------
|
||||
|
||||
* added the possibility to throttle messages per second in ThrottlerPlugin (mostly for Amazon SES)
|
||||
* switched mime.qpcontentencoder to automatically use the PHP native encoder on PHP 5.4.7+
|
||||
* allowed specifying a whitelist with regular expressions in RedirectingPlugin
|
||||
|
||||
4.2.1 (2012-07-13)
|
||||
------------------
|
||||
|
||||
* changed the coding standards to PSR-1/2
|
||||
* fixed issue with autoloading
|
||||
* added NativeQpContentEncoder to enhance performance (for PHP 5.3+)
|
||||
|
||||
4.2.0 (2012-06-29)
|
||||
------------------
|
||||
|
||||
* added documentation about how to use the Japanese support introduced in 4.1.8
|
||||
* added a way to override the default configuration in a lazy way
|
||||
* changed the PEAR init script to lazy-load the initialization
|
||||
* fixed a bug when calling Swift_Preferences before anything else (regression introduced in 4.1.8)
|
||||
|
||||
4.1.8 (2012-06-17)
|
||||
------------------
|
||||
|
||||
* added Japanese iso-2022-jp support
|
||||
* changed the init script to lazy-load the initialization
|
||||
* fixed docblocks (@id) which caused some problems with libraries parsing the dobclocks
|
||||
* fixed Swift_Mime_Headers_IdentificationHeader::setId() when passed an array of ids
|
||||
* fixed encoding of email addresses in headers
|
||||
* added replacements setter to the Decorator plugin
|
||||
|
||||
4.1.7 (2012-04-26)
|
||||
------------------
|
||||
|
||||
* fixed QpEncoder safeMapShareId property
|
||||
|
||||
4.1.6 (2012-03-23)
|
||||
------------------
|
||||
|
||||
* reduced the size of serialized Messages
|
||||
|
||||
4.1.5 (2012-01-04)
|
||||
------------------
|
||||
|
||||
* enforced Swift_Spool::queueMessage() to return a Boolean
|
||||
* made an optimization to the memory spool: start the transport only when required
|
||||
* prevented stream_socket_client() from generating an error and throw a Swift_TransportException instead
|
||||
* fixed a PHP warning when calling to mail() when safe_mode is off
|
||||
* many doc tweaks
|
||||
|
||||
4.1.4 (2011-12-16)
|
||||
------------------
|
||||
|
||||
* added a memory spool (Swift_MemorySpool)
|
||||
* fixed too many opened files when sending emails with attachments
|
||||
|
||||
4.1.3 (2011-10-27)
|
||||
------------------
|
||||
|
||||
* added STARTTLS support
|
||||
* added missing @return tags on fluent methods
|
||||
* added a MessageLogger plugin that logs all sent messages
|
||||
* added composer.json
|
||||
|
||||
4.1.2 (2011-09-13)
|
||||
------------------
|
||||
|
||||
* fixed wrong detection of magic_quotes_runtime
|
||||
* fixed fatal errors when no To or Subject header has been set
|
||||
* fixed charset on parameter header continuations
|
||||
* added documentation about how to install Swiftmailer from the PEAR channel
|
||||
* fixed various typos and markup problem in the documentation
|
||||
* fixed warning when cache directory does not exist
|
||||
* fixed "slashes are escaped" bug
|
||||
* changed require_once() to require() in autoload
|
||||
|
||||
4.1.1 (2011-07-04)
|
||||
------------------
|
||||
|
||||
* added missing file in PEAR package
|
||||
|
||||
4.1.0 (2011-06-30)
|
||||
------------------
|
||||
|
||||
* documentation has been converted to ReST
|
||||
|
||||
4.1.0 RC1 (2011-06-17)
|
||||
----------------------
|
||||
|
||||
New features:
|
||||
|
||||
* changed the Decorator Plugin to allow replacements in all headers
|
||||
* added Swift_Mime_Grammar and Swift_Validate to validate an email address
|
||||
* modified the autoloader to lazy-initialize Swiftmailer
|
||||
* removed Swift_Mailer::batchSend()
|
||||
* added NullTransport
|
||||
* added new plugins: RedirectingPlugin and ImpersonatePlugin
|
||||
* added a way to send messages asynchronously (Spool)
|
||||
19
lib/composer/vendor/swiftmailer/swiftmailer/LICENSE
vendored
Normal file
19
lib/composer/vendor/swiftmailer/swiftmailer/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2013-2016 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
15
lib/composer/vendor/swiftmailer/swiftmailer/README
vendored
Normal file
15
lib/composer/vendor/swiftmailer/swiftmailer/README
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
Swift Mailer
|
||||
------------
|
||||
|
||||
Swift Mailer is a component based mailing solution for PHP 7.
|
||||
It is released under the MIT license.
|
||||
|
||||
Homepage: https://swiftmailer.symfony.com/
|
||||
Documentation: https://swiftmailer.symfony.com/docs/introduction.html
|
||||
Bugs: https://github.com/swiftmailer/swiftmailer/issues
|
||||
Repository: https://github.com/swiftmailer/swiftmailer
|
||||
|
||||
Swift Mailer is highly object-oriented by design and lends itself
|
||||
to use in complex web application with a great deal of flexibility.
|
||||
|
||||
For full details on usage, see the documentation.
|
||||
36
lib/composer/vendor/swiftmailer/swiftmailer/composer.json
vendored
Normal file
36
lib/composer/vendor/swiftmailer/swiftmailer/composer.json
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "swiftmailer/swiftmailer",
|
||||
"type": "library",
|
||||
"description": "Swiftmailer, free feature-rich PHP mailer",
|
||||
"keywords": ["mail","mailer","email"],
|
||||
"homepage": "http://swiftmailer.symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Chris Corbyn"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.0.0",
|
||||
"egulias/email-validator": "~2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9.1",
|
||||
"symfony/phpunit-bridge": "~3.3@dev"
|
||||
},
|
||||
"autoload": {
|
||||
"files": ["lib/swift_required.php"]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-0": { "Swift_": "tests/unit" }
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "6.0-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
609
lib/composer/vendor/swiftmailer/swiftmailer/doc/headers.rst
vendored
Normal file
609
lib/composer/vendor/swiftmailer/swiftmailer/doc/headers.rst
vendored
Normal file
@@ -0,0 +1,609 @@
|
||||
Message Headers
|
||||
===============
|
||||
|
||||
Sometimes you'll want to add your own headers to a message or modify/remove
|
||||
headers that are already present. You work with the message's HeaderSet to do
|
||||
this.
|
||||
|
||||
Header Basics
|
||||
-------------
|
||||
|
||||
All MIME entities in Swift Mailer -- including the message itself -- store
|
||||
their headers in a single object called a HeaderSet. This HeaderSet is
|
||||
retrieved with the ``getHeaders()`` method.
|
||||
|
||||
As mentioned in the previous chapter, everything that forms a part of a message
|
||||
in Swift Mailer is a MIME entity that is represented by an instance of
|
||||
``Swift_Mime_SimpleMimeEntity``. This includes -- most notably -- the message
|
||||
object itself, attachments, MIME parts and embedded images. Each of these MIME
|
||||
entities consists of a body and a set of headers that describe the body.
|
||||
|
||||
For all of the "standard" headers in these MIME entities, such as the
|
||||
``Content-Type``, there are named methods for working with them, such as
|
||||
``setContentType()`` and ``getContentType()``. This is because headers are a
|
||||
moderately complex area of the library. Each header has a slightly different
|
||||
required structure that it must meet in order to comply with the standards that
|
||||
govern email (and that are checked by spam blockers etc).
|
||||
|
||||
You fetch the HeaderSet from a MIME entity like so::
|
||||
|
||||
$message = new Swift_Message();
|
||||
|
||||
// Fetch the HeaderSet from a Message object
|
||||
$headers = $message->getHeaders();
|
||||
|
||||
$attachment = Swift_Attachment::fromPath('document.pdf');
|
||||
|
||||
// Fetch the HeaderSet from an attachment object
|
||||
$headers = $attachment->getHeaders();
|
||||
|
||||
The job of the HeaderSet is to contain and manage instances of Header objects.
|
||||
Depending upon the MIME entity the HeaderSet came from, the contents of the
|
||||
HeaderSet will be different, since an attachment for example has a different
|
||||
set of headers to those in a message.
|
||||
|
||||
You can find out what the HeaderSet contains with a quick loop, dumping out the
|
||||
names of the headers::
|
||||
|
||||
foreach ($headers->getAll() as $header) {
|
||||
printf("%s<br />\n", $header->getFieldName());
|
||||
}
|
||||
|
||||
/*
|
||||
Content-Transfer-Encoding
|
||||
Content-Type
|
||||
MIME-Version
|
||||
Date
|
||||
Message-ID
|
||||
From
|
||||
Subject
|
||||
To
|
||||
*/
|
||||
|
||||
You can also dump out the rendered HeaderSet by calling its ``toString()``
|
||||
method::
|
||||
|
||||
echo $headers->toString();
|
||||
|
||||
/*
|
||||
Message-ID: <1234869991.499a9ee7f1d5e@swift.generated>
|
||||
Date: Tue, 17 Feb 2009 22:26:31 +1100
|
||||
Subject: Awesome subject!
|
||||
From: sender@example.org
|
||||
To: recipient@example.org
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=utf-8
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
*/
|
||||
|
||||
Where the complexity comes in is when you want to modify an existing header.
|
||||
This complexity comes from the fact that each header can be of a slightly
|
||||
different type (such as a Date header, or a header that contains email
|
||||
addresses, or a header that has key-value parameters on it!). Each header in
|
||||
the HeaderSet is an instance of ``Swift_Mime_Header``. They all have common
|
||||
functionality, but knowing exactly what type of header you're working with will
|
||||
allow you a little more control.
|
||||
|
||||
You can determine the type of header by comparing the return value of its
|
||||
``getFieldType()`` method with the constants ``TYPE_TEXT``,
|
||||
``TYPE_PARAMETERIZED``, ``TYPE_DATE``, ``TYPE_MAILBOX``, ``TYPE_ID`` and
|
||||
``TYPE_PATH`` which are defined in ``Swift_Mime_Header``::
|
||||
|
||||
foreach ($headers->getAll() as $header) {
|
||||
switch ($header->getFieldType()) {
|
||||
case Swift_Mime_Header::TYPE_TEXT: $type = 'text';
|
||||
break;
|
||||
case Swift_Mime_Header::TYPE_PARAMETERIZED: $type = 'parameterized';
|
||||
break;
|
||||
case Swift_Mime_Header::TYPE_MAILBOX: $type = 'mailbox';
|
||||
break;
|
||||
case Swift_Mime_Header::TYPE_DATE: $type = 'date';
|
||||
break;
|
||||
case Swift_Mime_Header::TYPE_ID: $type = 'ID';
|
||||
break;
|
||||
case Swift_Mime_Header::TYPE_PATH: $type = 'path';
|
||||
break;
|
||||
}
|
||||
printf("%s: is a %s header<br />\n", $header->getFieldName(), $type);
|
||||
}
|
||||
|
||||
/*
|
||||
Content-Transfer-Encoding: is a text header
|
||||
Content-Type: is a parameterized header
|
||||
MIME-Version: is a text header
|
||||
Date: is a date header
|
||||
Message-ID: is a ID header
|
||||
From: is a mailbox header
|
||||
Subject: is a text header
|
||||
To: is a mailbox header
|
||||
*/
|
||||
|
||||
Headers can be removed from the set, modified within the set, or added to the
|
||||
set.
|
||||
|
||||
The following sections show you how to work with the HeaderSet and explain the
|
||||
details of each implementation of ``Swift_Mime_Header`` that may exist within
|
||||
the HeaderSet.
|
||||
|
||||
Header Types
|
||||
------------
|
||||
|
||||
Because all headers are modeled on different data (dates, addresses, text!)
|
||||
there are different types of Header in Swift Mailer. Swift Mailer attempts to
|
||||
categorize all possible MIME headers into more general groups, defined by a
|
||||
small number of classes.
|
||||
|
||||
Text Headers
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Text headers are the simplest type of Header. They contain textual information
|
||||
with no special information included within it -- for example the Subject
|
||||
header in a message.
|
||||
|
||||
There's nothing particularly interesting about a text header, though it is
|
||||
probably the one you'd opt to use if you need to add a custom header to a
|
||||
message. It represents text just like you'd think it does. If the text contains
|
||||
characters that are not permitted in a message header (such as new lines, or
|
||||
non-ascii characters) then the header takes care of encoding the text so that
|
||||
it can be used.
|
||||
|
||||
No header -- including text headers -- in Swift Mailer is vulnerable to
|
||||
header-injection attacks. Swift Mailer breaks any attempt at header injection
|
||||
by encoding the dangerous data into a non-dangerous form.
|
||||
|
||||
It's easy to add a new text header to a HeaderSet. You do this by calling the
|
||||
HeaderSet's ``addTextHeader()`` method::
|
||||
|
||||
$message = new Swift_Message();
|
||||
$headers = $message->getHeaders();
|
||||
$headers->addTextHeader('Your-Header-Name', 'the header value');
|
||||
|
||||
Changing the value of an existing text header is done by calling it's
|
||||
``setValue()`` method::
|
||||
|
||||
$subject = $message->getHeaders()->get('Subject');
|
||||
$subject->setValue('new subject');
|
||||
|
||||
When output via ``toString()``, a text header produces something like the
|
||||
following::
|
||||
|
||||
$subject = $message->getHeaders()->get('Subject');
|
||||
$subject->setValue('amazing subject line');
|
||||
echo $subject->toString();
|
||||
|
||||
/*
|
||||
|
||||
Subject: amazing subject line
|
||||
|
||||
*/
|
||||
|
||||
If the header contains any characters that are outside of the US-ASCII range
|
||||
however, they will be encoded. This is nothing to be concerned about since mail
|
||||
clients will decode them back::
|
||||
|
||||
$subject = $message->getHeaders()->get('Subject');
|
||||
$subject->setValue('contains – dash');
|
||||
echo $subject->toString();
|
||||
|
||||
/*
|
||||
|
||||
Subject: contains =?utf-8?Q?=E2=80=93?= dash
|
||||
|
||||
*/
|
||||
|
||||
Parameterized Headers
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Parameterized headers are text headers that contain key-value parameters
|
||||
following the textual content. The Content-Type header of a message is a
|
||||
parameterized header since it contains charset information after the content
|
||||
type.
|
||||
|
||||
The parameterized header type is a special type of text header. It extends the
|
||||
text header by allowing additional information to follow it. All of the methods
|
||||
from text headers are available in addition to the methods described here.
|
||||
|
||||
Adding a parameterized header to a HeaderSet is done by using the
|
||||
``addParameterizedHeader()`` method which takes a text value like
|
||||
``addTextHeader()`` but it also accepts an associative array of key-value
|
||||
parameters::
|
||||
|
||||
$message = new Swift_Message();
|
||||
$headers = $message->getHeaders();
|
||||
$headers->addParameterizedHeader(
|
||||
'Header-Name', 'header value',
|
||||
['foo' => 'bar']
|
||||
);
|
||||
|
||||
To change the text value of the header, call it's ``setValue()`` method just as
|
||||
you do with text headers.
|
||||
|
||||
To change the parameters in the header, call the header's ``setParameters()``
|
||||
method or the ``setParameter()`` method (note the pluralization)::
|
||||
|
||||
$type = $message->getHeaders()->get('Content-Type');
|
||||
|
||||
// setParameters() takes an associative array
|
||||
$type->setParameters([
|
||||
'name' => 'file.txt',
|
||||
'charset' => 'iso-8859-1'
|
||||
]);
|
||||
|
||||
// setParameter() takes two args for $key and $value
|
||||
$type->setParameter('charset', 'iso-8859-1');
|
||||
|
||||
When output via ``toString()``, a parameterized header produces something like
|
||||
the following::
|
||||
|
||||
$type = $message->getHeaders()->get('Content-Type');
|
||||
$type->setValue('text/html');
|
||||
$type->setParameter('charset', 'utf-8');
|
||||
|
||||
echo $type->toString();
|
||||
|
||||
/*
|
||||
|
||||
Content-Type: text/html; charset=utf-8
|
||||
|
||||
*/
|
||||
|
||||
If the header contains any characters that are outside of the US-ASCII range
|
||||
however, they will be encoded, just like they are for text headers. This is
|
||||
nothing to be concerned about since mail clients will decode them back.
|
||||
Likewise, if the parameters contain any non-ascii characters they will be
|
||||
encoded so that they can be transmitted safely::
|
||||
|
||||
$attachment = new Swift_Attachment();
|
||||
$disp = $attachment->getHeaders()->get('Content-Disposition');
|
||||
$disp->setValue('attachment');
|
||||
$disp->setParameter('filename', 'report–may.pdf');
|
||||
echo $disp->toString();
|
||||
|
||||
/*
|
||||
|
||||
Content-Disposition: attachment; filename*=utf-8''report%E2%80%93may.pdf
|
||||
|
||||
*/
|
||||
|
||||
Date Headers
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Date headers contains an RFC 2822 formatted date (i.e. what PHP's ``date('r')``
|
||||
returns). They are used anywhere a date or time is needed to be presented as a
|
||||
message header.
|
||||
|
||||
The data on which a date header is modeled as a DateTimeImmutable object. The
|
||||
object is used to create a correctly structured RFC 2822 formatted date with
|
||||
timezone such as ``Tue, 17 Feb 2009 22:26:31 +1100``.
|
||||
|
||||
The obvious place this header type is used is in the ``Date:`` header of the
|
||||
message itself.
|
||||
|
||||
It's easy to add a new date header to a HeaderSet. You do this by calling the
|
||||
HeaderSet's ``addDateHeader()`` method::
|
||||
|
||||
$message = new Swift_Message();
|
||||
$headers = $message->getHeaders();
|
||||
$headers->addDateHeader('Your-Header', new DateTimeImmutable('3 days ago'));
|
||||
|
||||
Changing the value of an existing date header is done by calling it's
|
||||
``setDateTime()`` method::
|
||||
|
||||
$date = $message->getHeaders()->get('Date');
|
||||
$date->setDateTime(new DateTimeImmutable());
|
||||
|
||||
When output via ``toString()``, a date header produces something like the
|
||||
following::
|
||||
|
||||
$date = $message->getHeaders()->get('Date');
|
||||
echo $date->toString();
|
||||
|
||||
/*
|
||||
|
||||
Date: Wed, 18 Feb 2009 13:35:02 +1100
|
||||
|
||||
*/
|
||||
|
||||
Mailbox (e-mail address) Headers
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Mailbox headers contain one or more email addresses, possibly with personalized
|
||||
names attached to them. The data on which they are modeled is represented by an
|
||||
associative array of email addresses and names.
|
||||
|
||||
Mailbox headers are probably the most complex header type to understand in
|
||||
Swift Mailer because they accept their input as an array which can take various
|
||||
forms, as described in the previous chapter.
|
||||
|
||||
All of the headers that contain e-mail addresses in a message -- with the
|
||||
exception of ``Return-Path:`` which has a stricter syntax -- use this header
|
||||
type. That is, ``To:``, ``From:`` etc.
|
||||
|
||||
You add a new mailbox header to a HeaderSet by calling the HeaderSet's
|
||||
``addMailboxHeader()`` method::
|
||||
|
||||
$message = new Swift_Message();
|
||||
$headers = $message->getHeaders();
|
||||
$headers->addMailboxHeader('Your-Header-Name', [
|
||||
'person1@example.org' => 'Person Name One',
|
||||
'person2@example.org',
|
||||
'person3@example.org',
|
||||
'person4@example.org' => 'Another named person'
|
||||
]);
|
||||
|
||||
Changing the value of an existing mailbox header is done by calling it's
|
||||
``setNameAddresses()`` method::
|
||||
|
||||
$to = $message->getHeaders()->get('To');
|
||||
$to->setNameAddresses([
|
||||
'joe@example.org' => 'Joe Bloggs',
|
||||
'john@example.org' => 'John Doe',
|
||||
'no-name@example.org'
|
||||
]);
|
||||
|
||||
If you don't wish to concern yourself with the complicated accepted input
|
||||
formats accepted by ``setNameAddresses()`` as described in the previous chapter
|
||||
and you only want to set one or more addresses (not names) then you can just
|
||||
use the ``setAddresses()`` method instead::
|
||||
|
||||
$to = $message->getHeaders()->get('To');
|
||||
$to->setAddresses([
|
||||
'joe@example.org',
|
||||
'john@example.org',
|
||||
'no-name@example.org'
|
||||
]);
|
||||
|
||||
.. note::
|
||||
|
||||
Both methods will accept the above input format in practice.
|
||||
|
||||
If all you want to do is set a single address in the header, you can use a
|
||||
string as the input parameter to ``setAddresses()`` and/or
|
||||
``setNameAddresses()``::
|
||||
|
||||
$to = $message->getHeaders()->get('To');
|
||||
$to->setAddresses('joe-bloggs@example.org');
|
||||
|
||||
When output via ``toString()``, a mailbox header produces something like the
|
||||
following::
|
||||
|
||||
$to = $message->getHeaders()->get('To');
|
||||
$to->setNameAddresses([
|
||||
'person1@example.org' => 'Name of Person',
|
||||
'person2@example.org',
|
||||
'person3@example.org' => 'Another Person'
|
||||
]);
|
||||
|
||||
echo $to->toString();
|
||||
|
||||
/*
|
||||
|
||||
To: Name of Person <person1@example.org>, person2@example.org, Another Person
|
||||
<person3@example.org>
|
||||
|
||||
*/
|
||||
|
||||
ID Headers
|
||||
~~~~~~~~~~
|
||||
|
||||
ID headers contain identifiers for the entity (or the message). The most
|
||||
notable ID header is the Message-ID header on the message itself.
|
||||
|
||||
An ID that exists inside an ID header looks more-or-less less like an email
|
||||
address. For example, ``<1234955437.499becad62ec2@example.org>``. The part to
|
||||
the left of the @ sign is usually unique, based on the current time and some
|
||||
random factor. The part on the right is usually a domain name.
|
||||
|
||||
Any ID passed to the header's ``setId()`` method absolutely MUST conform to
|
||||
this structure, otherwise you'll get an Exception thrown at you by Swift Mailer
|
||||
(a ``Swift_RfcComplianceException``). This is to ensure that the generated
|
||||
email complies with relevant RFC documents and therefore is less likely to be
|
||||
blocked as spam.
|
||||
|
||||
It's easy to add a new ID header to a HeaderSet. You do this by calling the
|
||||
HeaderSet's ``addIdHeader()`` method::
|
||||
|
||||
$message = new Swift_Message();
|
||||
$headers = $message->getHeaders();
|
||||
$headers->addIdHeader('Your-Header-Name', '123456.unqiue@example.org');
|
||||
|
||||
Changing the value of an existing ID header is done by calling its ``setId()``
|
||||
method::
|
||||
|
||||
$msgId = $message->getHeaders()->get('Message-ID');
|
||||
$msgId->setId(time() . '.' . uniqid('thing') . '@example.org');
|
||||
|
||||
When output via ``toString()``, an ID header produces something like the
|
||||
following::
|
||||
|
||||
$msgId = $message->getHeaders()->get('Message-ID');
|
||||
echo $msgId->toString();
|
||||
|
||||
/*
|
||||
|
||||
Message-ID: <1234955437.499becad62ec2@example.org>
|
||||
|
||||
*/
|
||||
|
||||
Path Headers
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Path headers are like very-restricted mailbox headers. They contain a single
|
||||
email address with no associated name. The Return-Path header of a message is a
|
||||
path header.
|
||||
|
||||
You add a new path header to a HeaderSet by calling the HeaderSet's
|
||||
``addPathHeader()`` method::
|
||||
|
||||
$message = new Swift_Message();
|
||||
$headers = $message->getHeaders();
|
||||
$headers->addPathHeader('Your-Header-Name', 'person@example.org');
|
||||
|
||||
|
||||
Changing the value of an existing path header is done by calling its
|
||||
``setAddress()`` method::
|
||||
|
||||
$return = $message->getHeaders()->get('Return-Path');
|
||||
$return->setAddress('my-address@example.org');
|
||||
|
||||
When output via ``toString()``, a path header produces something like the
|
||||
following::
|
||||
|
||||
$return = $message->getHeaders()->get('Return-Path');
|
||||
$return->setAddress('person@example.org');
|
||||
echo $return->toString();
|
||||
|
||||
/*
|
||||
|
||||
Return-Path: <person@example.org>
|
||||
|
||||
*/
|
||||
|
||||
Header Operations
|
||||
-----------------
|
||||
|
||||
Working with the headers in a message involves knowing how to use the methods
|
||||
on the HeaderSet and on the individual Headers within the HeaderSet.
|
||||
|
||||
Adding new Headers
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
New headers can be added to the HeaderSet by using one of the provided
|
||||
``add..Header()`` methods.
|
||||
|
||||
The added header will appear in the message when it is sent::
|
||||
|
||||
// Adding a custom header to a message
|
||||
$message = new Swift_Message();
|
||||
$headers = $message->getHeaders();
|
||||
$headers->addTextHeader('X-Mine', 'something here');
|
||||
|
||||
// Adding a custom header to an attachment
|
||||
$attachment = Swift_Attachment::fromPath('/path/to/doc.pdf');
|
||||
$attachment->getHeaders()->addDateHeader('X-Created-Time', time());
|
||||
|
||||
Retrieving Headers
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Headers are retrieved through the HeaderSet's ``get()`` and ``getAll()``
|
||||
methods::
|
||||
|
||||
$headers = $message->getHeaders();
|
||||
|
||||
// Get the To: header
|
||||
$toHeader = $headers->get('To');
|
||||
|
||||
// Get all headers named "X-Foo"
|
||||
$fooHeaders = $headers->getAll('X-Foo');
|
||||
|
||||
// Get the second header named "X-Foo"
|
||||
$foo = $headers->get('X-Foo', 1);
|
||||
|
||||
// Get all headers that are present
|
||||
$all = $headers->getAll();
|
||||
|
||||
When using ``get()`` a single header is returned that matches the name (case
|
||||
insensitive) that is passed to it. When using ``getAll()`` with a header name,
|
||||
an array of headers with that name are returned. Calling ``getAll()`` with no
|
||||
arguments returns an array of all headers present in the entity.
|
||||
|
||||
.. note::
|
||||
|
||||
It's valid for some headers to appear more than once in a message (e.g.
|
||||
the Received header). For this reason ``getAll()`` exists to fetch all
|
||||
headers with a specified name. In addition, ``get()`` accepts an optional
|
||||
numerical index, starting from zero to specify which header you want more
|
||||
specifically.
|
||||
|
||||
.. note::
|
||||
|
||||
If you want to modify the contents of the header and you don't know for
|
||||
sure what type of header it is then you may need to check the type by
|
||||
calling its ``getFieldType()`` method.
|
||||
|
||||
Check if a Header Exists
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You can check if a named header is present in a HeaderSet by calling its
|
||||
``has()`` method::
|
||||
|
||||
$headers = $message->getHeaders();
|
||||
|
||||
// Check if the To: header exists
|
||||
if ($headers->has('To')) {
|
||||
echo 'To: exists';
|
||||
}
|
||||
|
||||
// Check if an X-Foo header exists twice (i.e. check for the 2nd one)
|
||||
if ($headers->has('X-Foo', 1)) {
|
||||
echo 'Second X-Foo header exists';
|
||||
}
|
||||
|
||||
If the header exists, ``true`` will be returned or ``false`` if not.
|
||||
|
||||
.. note::
|
||||
|
||||
It's valid for some headers to appear more than once in a message (e.g.
|
||||
the Received header). For this reason ``has()`` accepts an optional
|
||||
numerical index, starting from zero to specify which header you want to
|
||||
check more specifically.
|
||||
|
||||
Removing Headers
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Removing a Header from the HeaderSet is done by calling the HeaderSet's
|
||||
``remove()`` or ``removeAll()`` methods::
|
||||
|
||||
$headers = $message->getHeaders();
|
||||
|
||||
// Remove the Subject: header
|
||||
$headers->remove('Subject');
|
||||
|
||||
// Remove all X-Foo headers
|
||||
$headers->removeAll('X-Foo');
|
||||
|
||||
// Remove only the second X-Foo header
|
||||
$headers->remove('X-Foo', 1);
|
||||
|
||||
When calling ``remove()`` a single header will be removed. When calling
|
||||
``removeAll()`` all headers with the given name will be removed. If no headers
|
||||
exist with the given name, no errors will occur.
|
||||
|
||||
.. note::
|
||||
|
||||
It's valid for some headers to appear more than once in a message (e.g.
|
||||
the Received header). For this reason ``remove()`` accepts an optional
|
||||
numerical index, starting from zero to specify which header you want to
|
||||
check more specifically. For the same reason, ``removeAll()`` exists to
|
||||
remove all headers that have the given name.
|
||||
|
||||
Modifying a Header's Content
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
To change a Header's content you should know what type of header it is and then
|
||||
call it's appropriate setter method. All headers also have a
|
||||
``setFieldBodyModel()`` method that accepts a mixed parameter and delegates to
|
||||
the correct setter::
|
||||
|
||||
The header will be updated inside the HeaderSet and the changes will be seen
|
||||
when the message is sent::
|
||||
|
||||
$headers = $message->getHeaders();
|
||||
|
||||
// Change the Subject: header
|
||||
$subj = $headers->get('Subject');
|
||||
$subj->setValue('new subject here');
|
||||
|
||||
// Change the To: header
|
||||
$to = $headers->get('To');
|
||||
$to->setNameAddresses([
|
||||
'person@example.org' => 'Person',
|
||||
'thing@example.org'
|
||||
]);
|
||||
|
||||
// Using the setFieldBodyModel() just delegates to the correct method
|
||||
// So here to calls setNameAddresses()
|
||||
$to->setFieldBodyModel([
|
||||
'person@example.org' => 'Person',
|
||||
'thing@example.org'
|
||||
]);
|
||||
12
lib/composer/vendor/swiftmailer/swiftmailer/doc/index.rst
vendored
Normal file
12
lib/composer/vendor/swiftmailer/swiftmailer/doc/index.rst
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
Swiftmailer
|
||||
===========
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
introduction
|
||||
messages
|
||||
headers
|
||||
sending
|
||||
plugins
|
||||
japanese
|
||||
61
lib/composer/vendor/swiftmailer/swiftmailer/doc/introduction.rst
vendored
Normal file
61
lib/composer/vendor/swiftmailer/swiftmailer/doc/introduction.rst
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
Introduction
|
||||
============
|
||||
|
||||
Swift Mailer is a for sending e-mails from PHP applications.
|
||||
|
||||
System Requirements
|
||||
-------------------
|
||||
|
||||
Swift Mailer requires PHP 7.0 or higher (``proc_*`` functions must be
|
||||
available).
|
||||
|
||||
Swift Mailer does not work when used with function overloading as implemented
|
||||
by ``mbstring`` when ``mbstring.func_overload`` is set to ``2``.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
The recommended way to install Swiftmailer is via Composer:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ composer require "swiftmailer/swiftmailer:^6.0"
|
||||
|
||||
Basic Usage
|
||||
-----------
|
||||
|
||||
Here is the simplest way to send emails with Swift Mailer::
|
||||
|
||||
require_once '/path/to/vendor/autoload.php';
|
||||
|
||||
// Create the Transport
|
||||
$transport = (new Swift_SmtpTransport('smtp.example.org', 25))
|
||||
->setUsername('your username')
|
||||
->setPassword('your password')
|
||||
;
|
||||
|
||||
// Create the Mailer using your created Transport
|
||||
$mailer = new Swift_Mailer($transport);
|
||||
|
||||
// Create a message
|
||||
$message = (new Swift_Message('Wonderful Subject'))
|
||||
->setFrom(['john@doe.com' => 'John Doe'])
|
||||
->setTo(['receiver@domain.org', 'other@domain.org' => 'A name'])
|
||||
->setBody('Here is the message itself')
|
||||
;
|
||||
|
||||
// Send the message
|
||||
$result = $mailer->send($message);
|
||||
|
||||
You can also use Sendmail as a transport::
|
||||
|
||||
// Sendmail
|
||||
$transport = new Swift_SendmailTransport('/usr/sbin/sendmail -bs');
|
||||
|
||||
Getting Help
|
||||
------------
|
||||
|
||||
For general support, use `Stack Overflow <https://stackoverflow.com>`_.
|
||||
|
||||
For bug reports and feature requests, create a new ticket in `GitHub
|
||||
<https://github.com/swiftmailer/swiftmailer/issues>`_.
|
||||
19
lib/composer/vendor/swiftmailer/swiftmailer/doc/japanese.rst
vendored
Normal file
19
lib/composer/vendor/swiftmailer/swiftmailer/doc/japanese.rst
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Using Swift Mailer for Japanese Emails
|
||||
======================================
|
||||
|
||||
To send emails in Japanese, you need to tweak the default configuration.
|
||||
|
||||
Call the ``Swift::init()`` method with the following code as early as possible
|
||||
in your code::
|
||||
|
||||
Swift::init(function () {
|
||||
Swift_DependencyContainer::getInstance()
|
||||
->register('mime.qpheaderencoder')
|
||||
->asAliasOf('mime.base64headerencoder');
|
||||
|
||||
Swift_Preferences::getInstance()->setCharset('iso-2022-jp');
|
||||
});
|
||||
|
||||
/* rest of code goes here */
|
||||
|
||||
That's all!
|
||||
908
lib/composer/vendor/swiftmailer/swiftmailer/doc/messages.rst
vendored
Normal file
908
lib/composer/vendor/swiftmailer/swiftmailer/doc/messages.rst
vendored
Normal file
@@ -0,0 +1,908 @@
|
||||
Creating Messages
|
||||
=================
|
||||
|
||||
Creating messages in Swift Mailer is done by making use of the various MIME
|
||||
entities provided with the library. Complex messages can be quickly created
|
||||
with very little effort.
|
||||
|
||||
Quick Reference
|
||||
---------------
|
||||
|
||||
You can think of creating a Message as being similar to the steps you perform
|
||||
when you click the Compose button in your mail client. You give it a subject,
|
||||
specify some recipients, add any attachments and write your message::
|
||||
|
||||
// Create the message
|
||||
$message = (new Swift_Message())
|
||||
|
||||
// Give the message a subject
|
||||
->setSubject('Your subject')
|
||||
|
||||
// Set the From address with an associative array
|
||||
->setFrom(['john@doe.com' => 'John Doe'])
|
||||
|
||||
// Set the To addresses with an associative array (setTo/setCc/setBcc)
|
||||
->setTo(['receiver@domain.org', 'other@domain.org' => 'A name'])
|
||||
|
||||
// Give it a body
|
||||
->setBody('Here is the message itself')
|
||||
|
||||
// And optionally an alternative body
|
||||
->addPart('<q>Here is the message itself</q>', 'text/html')
|
||||
|
||||
// Optionally add any attachments
|
||||
->attach(Swift_Attachment::fromPath('my-document.pdf'))
|
||||
;
|
||||
|
||||
Message Basics
|
||||
--------------
|
||||
|
||||
A message is a container for anything you want to send to somebody else. There
|
||||
are several basic aspects of a message that you should know.
|
||||
|
||||
An e-mail message is made up of several relatively simple entities that are
|
||||
combined in different ways to achieve different results. All of these entities
|
||||
have the same fundamental outline but serve a different purpose. The Message
|
||||
itself can be defined as a MIME entity, an Attachment is a MIME entity, all
|
||||
MIME parts are MIME entities -- and so on!
|
||||
|
||||
The basic units of each MIME entity -- be it the Message itself, or an
|
||||
Attachment -- are its Headers and its body:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
Header-Name: A header value
|
||||
Other-Header: Another value
|
||||
|
||||
The body content itself
|
||||
|
||||
The Headers of a MIME entity, and its body must conform to some strict
|
||||
standards defined by various RFC documents. Swift Mailer ensures that these
|
||||
specifications are followed by using various types of object, including
|
||||
Encoders and different Header types to generate the entity.
|
||||
|
||||
The Structure of a Message
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Of all of the MIME entities, a message -- ``Swift_Message`` is the largest and
|
||||
most complex. It has many properties that can be updated and it can contain
|
||||
other MIME entities -- attachments for example -- nested inside it.
|
||||
|
||||
A Message has a lot of different Headers which are there to present information
|
||||
about the message to the recipients' mail client. Most of these headers will be
|
||||
familiar to the majority of users, but we'll list the basic ones. Although it's
|
||||
possible to work directly with the Headers of a Message (or other MIME entity),
|
||||
the standard Headers have accessor methods provided to abstract away the
|
||||
complex details for you. For example, although the Date on a message is written
|
||||
with a strict format, you only need to pass a DateTimeInterface instance to
|
||||
``setDate()``.
|
||||
|
||||
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+
|
||||
| Header | Description | Accessors |
|
||||
+===============================+====================================================================================================================================+=============================================+
|
||||
| ``Message-ID`` | Identifies this message with a unique ID, usually containing the domain name and time generated | ``getId()`` / ``setId()`` |
|
||||
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+
|
||||
| ``Return-Path`` | Specifies where bounces should go (Swift Mailer reads this for other uses) | ``getReturnPath()`` / ``setReturnPath()`` |
|
||||
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+
|
||||
| ``From`` | Specifies the address of the person who the message is from. This can be multiple addresses if multiple people wrote the message. | ``getFrom()`` / ``setFrom()`` |
|
||||
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+
|
||||
| ``Sender`` | Specifies the address of the person who physically sent the message (higher precedence than ``From:``) | ``getSender()`` / ``setSender()`` |
|
||||
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+
|
||||
| ``To`` | Specifies the addresses of the intended recipients | ``getTo()`` / ``setTo()`` |
|
||||
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+
|
||||
| ``Cc`` | Specifies the addresses of recipients who will be copied in on the message | ``getCc()`` / ``setCc()`` |
|
||||
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+
|
||||
| ``Bcc`` | Specifies the addresses of recipients who the message will be blind-copied to. Other recipients will not be aware of these copies. | ``getBcc()`` / ``setBcc()`` |
|
||||
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+
|
||||
| ``Reply-To`` | Specifies the address where replies are sent to | ``getReplyTo()`` / ``setReplyTo()`` |
|
||||
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+
|
||||
| ``Subject`` | Specifies the subject line that is displayed in the recipients' mail client | ``getSubject()`` / ``setSubject()`` |
|
||||
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+
|
||||
| ``Date`` | Specifies the date at which the message was sent | ``getDate()`` / ``setDate()`` |
|
||||
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+
|
||||
| ``Content-Type`` | Specifies the format of the message (usually text/plain or text/html) | ``getContentType()`` / ``setContentType()`` |
|
||||
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+
|
||||
| ``Content-Transfer-Encoding`` | Specifies the encoding scheme in the message | ``getEncoder()`` / ``setEncoder()`` |
|
||||
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+
|
||||
|
||||
Working with a Message Object
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Although there are a lot of available methods on a message object, you only
|
||||
need to make use of a small subset of them. Usually you'll use
|
||||
``setSubject()``, ``setTo()`` and ``setFrom()`` before setting the body of your
|
||||
message with ``setBody()``::
|
||||
|
||||
$message = new Swift_Message();
|
||||
$message->setSubject('My subject');
|
||||
|
||||
All MIME entities (including a message) have a ``toString()`` method that you
|
||||
can call if you want to take a look at what is going to be sent. For example,
|
||||
if you ``echo $message->toString();`` you would see something like this:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
Message-ID: <1230173678.4952f5eeb1432@swift.generated>
|
||||
Date: Thu, 25 Dec 2008 13:54:38 +1100
|
||||
Subject: Example subject
|
||||
From: Chris Corbyn <chris@w3style.co.uk>
|
||||
To: Receiver Name <recipient@example.org>
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=utf-8
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
|
||||
Here is the message
|
||||
|
||||
We'll take a closer look at the methods you use to create your message in the
|
||||
following sections.
|
||||
|
||||
Adding Content to Your Message
|
||||
------------------------------
|
||||
|
||||
Rich content can be added to messages in Swift Mailer with relative ease by
|
||||
calling methods such as ``setSubject()``, ``setBody()``, ``addPart()`` and
|
||||
``attach()``.
|
||||
|
||||
Setting the Subject Line
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The subject line, displayed in the recipients' mail client can be set with the
|
||||
``setSubject()`` method, or as a parameter to ``new Swift_Message()``::
|
||||
|
||||
// Pass it as a parameter when you create the message
|
||||
$message = new Swift_Message('My amazing subject');
|
||||
|
||||
// Or set it after like this
|
||||
$message->setSubject('My amazing subject');
|
||||
|
||||
Setting the Body Content
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The body of the message -- seen when the user opens the message -- is specified
|
||||
by calling the ``setBody()`` method. If an alternative body is to be included,
|
||||
``addPart()`` can be used.
|
||||
|
||||
The body of a message is the main part that is read by the user. Often people
|
||||
want to send a message in HTML format (``text/html``), other times people want
|
||||
to send in plain text (``text/plain``), or sometimes people want to send both
|
||||
versions and allow the recipient to choose how they view the message.
|
||||
|
||||
As a rule of thumb, if you're going to send a HTML email, always include a
|
||||
plain-text equivalent of the same content so that users who prefer to read
|
||||
plain text can do so.
|
||||
|
||||
If the recipient's mail client offers preferences for displaying text vs. HTML
|
||||
then the mail client will present that part to the user where available. In
|
||||
other cases the mail client will display the "best" part it can - usually HTML
|
||||
if you've included HTML::
|
||||
|
||||
// Pass it as a parameter when you create the message
|
||||
$message = new Swift_Message('Subject here', 'My amazing body');
|
||||
|
||||
// Or set it after like this
|
||||
$message->setBody('My <em>amazing</em> body', 'text/html');
|
||||
|
||||
// Add alternative parts with addPart()
|
||||
$message->addPart('My amazing body in plain text', 'text/plain');
|
||||
|
||||
Attaching Files
|
||||
---------------
|
||||
|
||||
Attachments are downloadable parts of a message and can be added by calling the
|
||||
``attach()`` method on the message. You can add attachments that exist on disk,
|
||||
or you can create attachments on-the-fly.
|
||||
|
||||
Although we refer to files sent over e-mails as "attachments" -- because
|
||||
they're attached to the message -- lots of other parts of the message are
|
||||
actually "attached" even if we don't refer to these parts as attachments.
|
||||
|
||||
File attachments are created by the ``Swift_Attachment`` class and then
|
||||
attached to the message via the ``attach()`` method on it. For all of the
|
||||
"every day" MIME types such as all image formats, word documents, PDFs and
|
||||
spreadsheets you don't need to explicitly set the content-type of the
|
||||
attachment, though it would do no harm to do so. For less common formats you
|
||||
should set the content-type -- which we'll cover in a moment.
|
||||
|
||||
Attaching Existing Files
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Files that already exist, either on disk or at a URL can be attached to a
|
||||
message with just one line of code, using ``Swift_Attachment::fromPath()``.
|
||||
|
||||
You can attach files that exist locally, or if your PHP installation has
|
||||
``allow_url_fopen`` turned on you can attach files from other
|
||||
websites.
|
||||
|
||||
The attachment will be presented to the recipient as a downloadable file with
|
||||
the same filename as the one you attached::
|
||||
|
||||
// Create the attachment
|
||||
// * Note that you can technically leave the content-type parameter out
|
||||
$attachment = Swift_Attachment::fromPath('/path/to/image.jpg', 'image/jpeg');
|
||||
|
||||
// Attach it to the message
|
||||
$message->attach($attachment);
|
||||
|
||||
|
||||
// The two statements above could be written in one line instead
|
||||
$message->attach(Swift_Attachment::fromPath('/path/to/image.jpg'));
|
||||
|
||||
|
||||
// You can attach files from a URL if allow_url_fopen is on in php.ini
|
||||
$message->attach(Swift_Attachment::fromPath('http://site.tld/logo.png'));
|
||||
|
||||
Setting the Filename
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Usually you don't need to explicitly set the filename of an attachment because
|
||||
the name of the attached file will be used by default, but if you want to set
|
||||
the filename you use the ``setFilename()`` method of the Attachment.
|
||||
|
||||
The attachment will be attached in the normal way, but meta-data sent inside
|
||||
the email will rename the file to something else::
|
||||
|
||||
// Create the attachment and call its setFilename() method
|
||||
$attachment = Swift_Attachment::fromPath('/path/to/image.jpg')
|
||||
->setFilename('cool.jpg');
|
||||
|
||||
|
||||
// Because there's a fluid interface, you can do this in one statement
|
||||
$message->attach(
|
||||
Swift_Attachment::fromPath('/path/to/image.jpg')->setFilename('cool.jpg')
|
||||
);
|
||||
|
||||
Attaching Dynamic Content
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Files that are generated at runtime, such as PDF documents or images created
|
||||
via GD can be attached directly to a message without writing them out to disk.
|
||||
Use ``Swift_Attachment`` directly.
|
||||
|
||||
The attachment will be presented to the recipient as a downloadable file
|
||||
with the filename and content-type you specify::
|
||||
|
||||
// Create your file contents in the normal way, but don't write them to disk
|
||||
$data = create_my_pdf_data();
|
||||
|
||||
// Create the attachment with your data
|
||||
$attachment = new Swift_Attachment($data, 'my-file.pdf', 'application/pdf');
|
||||
|
||||
// Attach it to the message
|
||||
$message->attach($attachment);
|
||||
|
||||
|
||||
// You can alternatively use method chaining to build the attachment
|
||||
$attachment = (new Swift_Attachment())
|
||||
->setFilename('my-file.pdf')
|
||||
->setContentType('application/pdf')
|
||||
->setBody($data)
|
||||
;
|
||||
|
||||
.. note::
|
||||
|
||||
If you would usually write the file to disk anyway you should just attach
|
||||
it with ``Swift_Attachment::fromPath()`` since this will use less memory.
|
||||
|
||||
Changing the Disposition
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Attachments just appear as files that can be saved to the Desktop if desired.
|
||||
You can make attachment appear inline where possible by using the
|
||||
``setDisposition()`` method of an attachment.
|
||||
|
||||
The attachment will be displayed within the email viewing window if the mail
|
||||
client knows how to display it::
|
||||
|
||||
// Create the attachment and call its setDisposition() method
|
||||
$attachment = Swift_Attachment::fromPath('/path/to/image.jpg')
|
||||
->setDisposition('inline');
|
||||
|
||||
|
||||
// Because there's a fluid interface, you can do this in one statement
|
||||
$message->attach(
|
||||
Swift_Attachment::fromPath('/path/to/image.jpg')->setDisposition('inline')
|
||||
);
|
||||
|
||||
.. note::
|
||||
|
||||
If you try to create an inline attachment for a non-displayable file type
|
||||
such as a ZIP file, the mail client should just present the attachment as
|
||||
normal.
|
||||
|
||||
Embedding Inline Media Files
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Often, people want to include an image or other content inline with a HTML
|
||||
message. It's easy to do this with HTML linking to remote resources, but this
|
||||
approach is usually blocked by mail clients. Swift Mailer allows you to embed
|
||||
your media directly into the message.
|
||||
|
||||
Mail clients usually block downloads from remote resources because this
|
||||
technique was often abused as a mean of tracking who opened an email. If
|
||||
you're sending a HTML email and you want to include an image in the message
|
||||
another approach you can take is to embed the image directly.
|
||||
|
||||
Swift Mailer makes embedding files into messages extremely streamlined. You
|
||||
embed a file by calling the ``embed()`` method of the message,
|
||||
which returns a value you can use in a ``src`` or
|
||||
``href`` attribute in your HTML.
|
||||
|
||||
Just like with attachments, it's possible to embed dynamically generated
|
||||
content without having an existing file available.
|
||||
|
||||
The embedded files are sent in the email as a special type of attachment that
|
||||
has a unique ID used to reference them within your HTML attributes. On mail
|
||||
clients that do not support embedded files they may appear as attachments.
|
||||
|
||||
Although this is commonly done for images, in theory it will work for any
|
||||
displayable (or playable) media type. Support for other media types (such as
|
||||
video) is dependent on the mail client however.
|
||||
|
||||
Embedding Existing Files
|
||||
........................
|
||||
|
||||
Files that already exist, either on disk or at a URL can be embedded in a
|
||||
message with just one line of code, using ``Swift_EmbeddedFile::fromPath()``.
|
||||
|
||||
You can embed files that exist locally, or if your PHP installation has
|
||||
``allow_url_fopen`` turned on you can embed files from other websites.
|
||||
|
||||
The file will be displayed with the message inline with the HTML wherever its ID
|
||||
is used as a ``src`` attribute::
|
||||
|
||||
// Create the message
|
||||
$message = new Swift_Message('My subject');
|
||||
|
||||
// Set the body
|
||||
$message->setBody(
|
||||
'<html>' .
|
||||
' <body>' .
|
||||
' Here is an image <img src="' . // Embed the file
|
||||
$message->embed(Swift_Image::fromPath('image.png')) .
|
||||
'" alt="Image" />' .
|
||||
' Rest of message' .
|
||||
' </body>' .
|
||||
'</html>',
|
||||
'text/html' // Mark the content-type as HTML
|
||||
);
|
||||
|
||||
// You can embed files from a URL if allow_url_fopen is on in php.ini
|
||||
$message->setBody(
|
||||
'<html>' .
|
||||
' <body>' .
|
||||
' Here is an image <img src="' .
|
||||
$message->embed(Swift_Image::fromPath('http://site.tld/logo.png')) .
|
||||
'" alt="Image" />' .
|
||||
' Rest of message' .
|
||||
' </body>' .
|
||||
'</html>',
|
||||
'text/html'
|
||||
);
|
||||
|
||||
.. note::
|
||||
|
||||
``Swift_Image`` and ``Swift_EmbeddedFile`` are just aliases of one another.
|
||||
``Swift_Image`` exists for semantic purposes.
|
||||
|
||||
.. note::
|
||||
|
||||
You can embed files in two stages if you prefer. Just capture the return
|
||||
value of ``embed()`` in a variable and use that as the ``src`` attribute::
|
||||
|
||||
// If placing the embed() code inline becomes cumbersome
|
||||
// it's easy to do this in two steps
|
||||
$cid = $message->embed(Swift_Image::fromPath('image.png'));
|
||||
|
||||
$message->setBody(
|
||||
'<html>' .
|
||||
' <body>' .
|
||||
' Here is an image <img src="' . $cid . '" alt="Image" />' .
|
||||
' Rest of message' .
|
||||
' </body>' .
|
||||
'</html>',
|
||||
'text/html' // Mark the content-type as HTML
|
||||
);
|
||||
|
||||
Embedding Dynamic Content
|
||||
.........................
|
||||
|
||||
Images that are generated at runtime, such as images created via GD can be
|
||||
embedded directly to a message without writing them out to disk. Use the
|
||||
standard ``new Swift_Image()`` method.
|
||||
|
||||
The file will be displayed with the message inline with the HTML wherever its ID
|
||||
is used as a ``src`` attribute::
|
||||
|
||||
// Create your file contents in the normal way, but don't write them to disk
|
||||
$img_data = create_my_image_data();
|
||||
|
||||
// Create the message
|
||||
$message = new Swift_Message('My subject');
|
||||
|
||||
// Set the body
|
||||
$message->setBody(
|
||||
'<html>' .
|
||||
' <body>' .
|
||||
' Here is an image <img src="' . // Embed the file
|
||||
$message->embed(new Swift_Image($img_data, 'image.jpg', 'image/jpeg')) .
|
||||
'" alt="Image" />' .
|
||||
' Rest of message' .
|
||||
' </body>' .
|
||||
'</html>',
|
||||
'text/html' // Mark the content-type as HTML
|
||||
);
|
||||
|
||||
.. note::
|
||||
|
||||
``Swift_Image`` and ``Swift_EmbeddedFile`` are just aliases of one another.
|
||||
``Swift_Image`` exists for semantic purposes.
|
||||
|
||||
.. note::
|
||||
|
||||
You can embed files in two stages if you prefer. Just capture the return
|
||||
value of ``embed()`` in a variable and use that as the ``src`` attribute::
|
||||
|
||||
// If placing the embed() code inline becomes cumbersome
|
||||
// it's easy to do this in two steps
|
||||
$cid = $message->embed(new Swift_Image($img_data, 'image.jpg', 'image/jpeg'));
|
||||
|
||||
$message->setBody(
|
||||
'<html>' .
|
||||
' <body>' .
|
||||
' Here is an image <img src="' . $cid . '" alt="Image" />' .
|
||||
' Rest of message' .
|
||||
' </body>' .
|
||||
'</html>',
|
||||
'text/html' // Mark the content-type as HTML
|
||||
);
|
||||
|
||||
Adding Recipients to Your Message
|
||||
---------------------------------
|
||||
|
||||
Recipients are specified within the message itself via ``setTo()``, ``setCc()``
|
||||
and ``setBcc()``. Swift Mailer reads these recipients from the message when it
|
||||
gets sent so that it knows where to send the message to.
|
||||
|
||||
Message recipients are one of three types:
|
||||
|
||||
* ``To:`` recipients -- the primary recipients (required)
|
||||
|
||||
* ``Cc:`` recipients -- receive a copy of the message (optional)
|
||||
|
||||
* ``Bcc:`` recipients -- hidden from other recipients (optional)
|
||||
|
||||
Each type can contain one, or several addresses. It's possible to list only the
|
||||
addresses of the recipients, or you can personalize the address by providing
|
||||
the real name of the recipient.
|
||||
|
||||
Make sure to add only valid email addresses as recipients. If you try to add an
|
||||
invalid email address with ``setTo()``, ``setCc()`` or ``setBcc()``, Swift
|
||||
Mailer will throw a ``Swift_RfcComplianceException``.
|
||||
|
||||
If you add recipients automatically based on a data source that may contain
|
||||
invalid email addresses, you can prevent possible exceptions by validating the
|
||||
addresses using::
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\Validation\RFCValidation;
|
||||
|
||||
$validator = new EmailValidator();
|
||||
$validator->isValid("example@example.com", new RFCValidation()); //true
|
||||
and only adding addresses that validate. Another way would be to wrap your ``setTo()``, ``setCc()`` and
|
||||
``setBcc()`` calls in a try-catch block and handle the
|
||||
``Swift_RfcComplianceException`` in the catch block.
|
||||
|
||||
.. sidebar:: Syntax for Addresses
|
||||
|
||||
If you only wish to refer to a single email address (for example your
|
||||
``From:`` address) then you can just use a string::
|
||||
|
||||
$message->setFrom('some@address.tld');
|
||||
|
||||
If you want to include a name then you must use an associative array::
|
||||
|
||||
$message->setFrom(['some@address.tld' => 'The Name']);
|
||||
|
||||
If you want to include multiple addresses then you must use an array::
|
||||
|
||||
$message->setTo(['some@address.tld', 'other@address.tld']);
|
||||
|
||||
You can mix personalized (addresses with a name) and non-personalized
|
||||
addresses in the same list by mixing the use of associative and
|
||||
non-associative array syntax::
|
||||
|
||||
$message->setTo([
|
||||
'recipient-with-name@example.org' => 'Recipient Name One',
|
||||
'no-name@example.org', // Note that this is not a key-value pair
|
||||
'named-recipient@example.org' => 'Recipient Name Two'
|
||||
]);
|
||||
|
||||
Setting ``To:`` Recipients
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
``To:`` recipients are required in a message and are set with the ``setTo()``
|
||||
or ``addTo()`` methods of the message.
|
||||
|
||||
To set ``To:`` recipients, create the message object using either ``new
|
||||
Swift_Message( ... )`` or ``new Swift_Message( ... )``, then call the
|
||||
``setTo()`` method with a complete array of addresses, or use the ``addTo()``
|
||||
method to iteratively add recipients.
|
||||
|
||||
The ``setTo()`` method accepts input in various formats as described earlier in
|
||||
this chapter. The ``addTo()`` method takes either one or two parameters. The
|
||||
first being the email address and the second optional parameter being the name
|
||||
of the recipient.
|
||||
|
||||
``To:`` recipients are visible in the message headers and will be seen by the
|
||||
other recipients::
|
||||
|
||||
// Using setTo() to set all recipients in one go
|
||||
$message->setTo([
|
||||
'person1@example.org',
|
||||
'person2@otherdomain.org' => 'Person 2 Name',
|
||||
'person3@example.org',
|
||||
'person4@example.org',
|
||||
'person5@example.org' => 'Person 5 Name'
|
||||
]);
|
||||
|
||||
.. note::
|
||||
|
||||
Multiple calls to ``setTo()`` will not add new recipients -- each
|
||||
call overrides the previous calls. If you want to iteratively add
|
||||
recipients, use the ``addTo()`` method::
|
||||
|
||||
// Using addTo() to add recipients iteratively
|
||||
$message->addTo('person1@example.org');
|
||||
$message->addTo('person2@example.org', 'Person 2 Name');
|
||||
|
||||
Setting ``Cc:`` Recipients
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
``Cc:`` recipients are set with the ``setCc()`` or ``addCc()`` methods of the
|
||||
message.
|
||||
|
||||
To set ``Cc:`` recipients, create the message object using either ``new
|
||||
Swift_Message( ... )`` or ``new Swift_Message( ... )``, then call the
|
||||
``setCc()`` method with a complete array of addresses, or use the ``addCc()``
|
||||
method to iteratively add recipients.
|
||||
|
||||
The ``setCc()`` method accepts input in various formats as described earlier in
|
||||
this chapter. The ``addCc()`` method takes either one or two parameters. The
|
||||
first being the email address and the second optional parameter being the name
|
||||
of the recipient.
|
||||
|
||||
``Cc:`` recipients are visible in the message headers and will be seen by the
|
||||
other recipients::
|
||||
|
||||
// Using setTo() to set all recipients in one go
|
||||
$message->setTo([
|
||||
'person1@example.org',
|
||||
'person2@otherdomain.org' => 'Person 2 Name',
|
||||
'person3@example.org',
|
||||
'person4@example.org',
|
||||
'person5@example.org' => 'Person 5 Name'
|
||||
]);
|
||||
|
||||
.. note::
|
||||
|
||||
Multiple calls to ``setCc()`` will not add new recipients -- each call
|
||||
overrides the previous calls. If you want to iteratively add Cc:
|
||||
recipients, use the ``addCc()`` method::
|
||||
|
||||
// Using addCc() to add recipients iteratively
|
||||
$message->addCc('person1@example.org');
|
||||
$message->addCc('person2@example.org', 'Person 2 Name');
|
||||
|
||||
Setting ``Bcc:`` Recipients
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
``Bcc:`` recipients receive a copy of the message without anybody else knowing
|
||||
it, and are set with the ``setBcc()`` or ``addBcc()`` methods of the message.
|
||||
|
||||
To set ``Bcc:`` recipients, create the message object using either ``new
|
||||
Swift_Message( ... )`` or ``new Swift_Message( ... )``, then call the
|
||||
``setBcc()`` method with a complete array of addresses, or use the ``addBcc()``
|
||||
method to iteratively add recipients.
|
||||
|
||||
The ``setBcc()`` method accepts input in various formats as described earlier
|
||||
in this chapter. The ``addBcc()`` method takes either one or two parameters.
|
||||
The first being the email address and the second optional parameter being the
|
||||
name of the recipient.
|
||||
|
||||
Only the individual ``Bcc:`` recipient will see their address in the message
|
||||
headers. Other recipients (including other ``Bcc:`` recipients) will not see
|
||||
the address::
|
||||
|
||||
// Using setBcc() to set all recipients in one go
|
||||
$message->setBcc([
|
||||
'person1@example.org',
|
||||
'person2@otherdomain.org' => 'Person 2 Name',
|
||||
'person3@example.org',
|
||||
'person4@example.org',
|
||||
'person5@example.org' => 'Person 5 Name'
|
||||
]);
|
||||
|
||||
.. note::
|
||||
|
||||
Multiple calls to ``setBcc()`` will not add new recipients -- each call
|
||||
overrides the previous calls. If you want to iteratively add Bcc:
|
||||
recipients, use the ``addBcc()`` method::
|
||||
|
||||
// Using addBcc() to add recipients iteratively
|
||||
$message->addBcc('person1@example.org');
|
||||
$message->addBcc('person2@example.org', 'Person 2 Name');
|
||||
|
||||
Specifying Sender Details
|
||||
-------------------------
|
||||
|
||||
An email must include information about who sent it. Usually this is managed by
|
||||
the ``From:`` address, however there are other options.
|
||||
|
||||
The sender information is contained in three possible places:
|
||||
|
||||
* ``From:`` -- the address(es) of who wrote the message (required)
|
||||
|
||||
* ``Sender:`` -- the address of the single person who sent the message
|
||||
(optional)
|
||||
|
||||
* ``Return-Path:`` -- the address where bounces should go to (optional)
|
||||
|
||||
You must always include a ``From:`` address by using ``setFrom()`` on the
|
||||
message. Swift Mailer will use this as the default ``Return-Path:`` unless
|
||||
otherwise specified.
|
||||
|
||||
The ``Sender:`` address exists because the person who actually sent the email
|
||||
may not be the person who wrote the email. It has a higher precedence than the
|
||||
``From:`` address and will be used as the ``Return-Path:`` unless otherwise
|
||||
specified.
|
||||
|
||||
Setting the ``From:`` Address
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
A ``From:`` address is required and is set with the ``setFrom()`` method of the
|
||||
message. ``From:`` addresses specify who actually wrote the email, and usually
|
||||
who sent it.
|
||||
|
||||
What most people probably don't realize is that you can have more than one
|
||||
``From:`` address if more than one person wrote the email -- for example if an
|
||||
email was put together by a committee.
|
||||
|
||||
The ``From:`` address(es) are visible in the message headers and will be seen
|
||||
by the recipients.
|
||||
|
||||
.. note::
|
||||
|
||||
If you set multiple ``From:`` addresses then you absolutely must set a
|
||||
``Sender:`` address to indicate who physically sent the message.
|
||||
|
||||
::
|
||||
|
||||
// Set a single From: address
|
||||
$message->setFrom('your@address.tld');
|
||||
|
||||
// Set a From: address including a name
|
||||
$message->setFrom(['your@address.tld' => 'Your Name']);
|
||||
|
||||
// Set multiple From: addresses if multiple people wrote the email
|
||||
$message->setFrom([
|
||||
'person1@example.org' => 'Sender One',
|
||||
'person2@example.org' => 'Sender Two'
|
||||
]);
|
||||
|
||||
Setting the ``Sender:`` Address
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
A ``Sender:`` address specifies who sent the message and is set with the
|
||||
``setSender()`` method of the message.
|
||||
|
||||
The ``Sender:`` address is visible in the message headers and will be seen by
|
||||
the recipients.
|
||||
|
||||
This address will be used as the ``Return-Path:`` unless otherwise specified.
|
||||
|
||||
.. note::
|
||||
|
||||
If you set multiple ``From:`` addresses then you absolutely must set a
|
||||
``Sender:`` address to indicate who physically sent the message.
|
||||
|
||||
You must not set more than one sender address on a message because it's not
|
||||
possible for more than one person to send a single message::
|
||||
|
||||
$message->setSender('your@address.tld');
|
||||
|
||||
Setting the ``Return-Path:`` (Bounce) Address
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The ``Return-Path:`` address specifies where bounce notifications should be
|
||||
sent and is set with the ``setReturnPath()`` method of the message.
|
||||
|
||||
You can only have one ``Return-Path:`` and it must not include a personal name.
|
||||
|
||||
Bounce notifications will be sent to this address::
|
||||
|
||||
$message->setReturnPath('bounces@address.tld');
|
||||
|
||||
Signed/Encrypted Message
|
||||
------------------------
|
||||
|
||||
To increase the integrity/security of a message it is possible to sign and/or
|
||||
encrypt an message using one or multiple signers.
|
||||
|
||||
S/MIME
|
||||
~~~~~~
|
||||
|
||||
S/MIME can sign and/or encrypt a message using the OpenSSL extension.
|
||||
|
||||
When signing a message, the signer creates a signature of the entire content of
|
||||
the message (including attachments).
|
||||
|
||||
The certificate and private key must be PEM encoded, and can be either created
|
||||
using for example OpenSSL or obtained at an official Certificate Authority (CA).
|
||||
|
||||
**The recipient must have the CA certificate in the list of trusted issuers in
|
||||
order to verify the signature.**
|
||||
|
||||
**Make sure the certificate supports emailProtection.**
|
||||
|
||||
When using OpenSSL this can done by the including the *-addtrust
|
||||
emailProtection* parameter when creating the certificate::
|
||||
|
||||
$message = new Swift_Message();
|
||||
|
||||
$smimeSigner = new Swift_Signers_SMimeSigner();
|
||||
$smimeSigner->setSignCertificate('/path/to/certificate.pem', '/path/to/private-key.pem');
|
||||
$message->attachSigner($smimeSigner);
|
||||
|
||||
When the private key is secured using a passphrase use the following instead::
|
||||
|
||||
$message = new Swift_Message();
|
||||
|
||||
$smimeSigner = new Swift_Signers_SMimeSigner();
|
||||
$smimeSigner->setSignCertificate('/path/to/certificate.pem', ['/path/to/private-key.pem', 'passphrase']);
|
||||
$message->attachSigner($smimeSigner);
|
||||
|
||||
By default the signature is added as attachment, making the message still
|
||||
readable for mailing agents not supporting signed messages.
|
||||
|
||||
Storing the message as binary is also possible but not recommended::
|
||||
|
||||
$smimeSigner->setSignCertificate('/path/to/certificate.pem', '/path/to/private-key.pem', PKCS7_BINARY);
|
||||
|
||||
When encrypting the message (also known as enveloping), the entire message
|
||||
(including attachments) is encrypted using a certificate, and the recipient can
|
||||
then decrypt the message using corresponding private key.
|
||||
|
||||
Encrypting ensures nobody can read the contents of the message without the
|
||||
private key.
|
||||
|
||||
Normally the recipient provides a certificate for encrypting and keeping the
|
||||
decryption key private.
|
||||
|
||||
Using both signing and encrypting is also possible::
|
||||
|
||||
$message = new Swift_Message();
|
||||
|
||||
$smimeSigner = new Swift_Signers_SMimeSigner();
|
||||
$smimeSigner->setSignCertificate('/path/to/sign-certificate.pem', '/path/to/private-key.pem');
|
||||
$smimeSigner->setEncryptCertificate('/path/to/encrypt-certificate.pem');
|
||||
$message->attachSigner($smimeSigner);
|
||||
|
||||
The used encryption cipher can be set as the second parameter of
|
||||
setEncryptCertificate()
|
||||
|
||||
See http://php.net/manual/openssl.ciphers for a list of supported ciphers.
|
||||
|
||||
By default the message is first signed and then encrypted, this can be changed
|
||||
by adding::
|
||||
|
||||
$smimeSigner->setSignThenEncrypt(false);
|
||||
|
||||
**Changing this is not recommended as most mail agents don't support this
|
||||
none-standard way.**
|
||||
|
||||
Only when having trouble with sign then encrypt method, this should be changed.
|
||||
|
||||
Requesting a Read Receipt
|
||||
-------------------------
|
||||
|
||||
It is possible to request a read-receipt to be sent to an address when the
|
||||
email is opened. To request a read receipt set the address with
|
||||
``setReadReceiptTo()``:
|
||||
|
||||
$message->setReadReceiptTo('your@address.tld');
|
||||
|
||||
When the email is opened, if the mail client supports it a notification will be
|
||||
sent to this address.
|
||||
|
||||
.. note::
|
||||
|
||||
Read receipts won't work for the majority of recipients since many mail
|
||||
clients auto-disable them. Those clients that will send a read receipt
|
||||
will make the user aware that one has been requested.
|
||||
|
||||
Setting the Character Set
|
||||
-------------------------
|
||||
|
||||
The character set of the message (and it's MIME parts) is set with the
|
||||
``setCharset()`` method. You can also change the global default of UTF-8 by
|
||||
working with the ``Swift_Preferences`` class.
|
||||
|
||||
Swift Mailer will default to the UTF-8 character set unless otherwise
|
||||
overridden. UTF-8 will work in most instances since it includes all of the
|
||||
standard US keyboard characters in addition to most international characters.
|
||||
|
||||
It is absolutely vital however that you know what character set your message
|
||||
(or it's MIME parts) are written in otherwise your message may be received
|
||||
completely garbled.
|
||||
|
||||
There are two places in Swift Mailer where you can change the character set:
|
||||
|
||||
* In the ``Swift_Preferences`` class
|
||||
|
||||
* On each individual message and/or MIME part
|
||||
|
||||
To set the character set of your Message:
|
||||
|
||||
* Change the global UTF-8 setting by calling
|
||||
``Swift_Preferences::setCharset()``; or
|
||||
|
||||
* Call the ``setCharset()`` method on the message or the MIME part::
|
||||
|
||||
// Approach 1: Change the global setting (suggested)
|
||||
Swift_Preferences::getInstance()->setCharset('iso-8859-2');
|
||||
|
||||
// Approach 2: Call the setCharset() method of the message
|
||||
$message = (new Swift_Message())
|
||||
->setCharset('iso-8859-2');
|
||||
|
||||
// Approach 3: Specify the charset when setting the body
|
||||
$message->setBody('My body', 'text/html', 'iso-8859-2');
|
||||
|
||||
// Approach 4: Specify the charset for each part added
|
||||
$message->addPart('My part', 'text/plain', 'iso-8859-2');
|
||||
|
||||
Setting the Line Length
|
||||
-----------------------
|
||||
|
||||
The length of lines in a message can be changed by using the
|
||||
``setMaxLineLength()`` method on the message::
|
||||
|
||||
$message->setMaxLineLength(1000);
|
||||
|
||||
Swift Mailer defaults to using 78 characters per line in a message. This is
|
||||
done for historical reasons and so that the message can be easily viewed in
|
||||
plain-text terminals
|
||||
|
||||
Lines that are longer than the line length specified will be wrapped between
|
||||
words.
|
||||
|
||||
.. note::
|
||||
|
||||
You should never set a maximum length longer than 1000 characters
|
||||
according to RFC 2822. Doing so could have unspecified side-effects such
|
||||
as truncating parts of your message when it is transported between SMTP
|
||||
servers.
|
||||
|
||||
Setting the Message Priority
|
||||
----------------------------
|
||||
|
||||
You can change the priority of the message with ``setPriority()``. Setting the
|
||||
priority will not change the way your email is sent -- it is purely an
|
||||
indicative setting for the recipient::
|
||||
|
||||
// Indicate "High" priority
|
||||
$message->setPriority(2);
|
||||
|
||||
The priority of a message is an indication to the recipient what significance
|
||||
it has. Swift Mailer allows you to set the priority by calling the
|
||||
``setPriority`` method. This method takes an integer value between 1 and 5:
|
||||
|
||||
* ``Swift_Mime_SimpleMessage::PRIORITY_HIGHEST``: 1
|
||||
* ``Swift_Mime_SimpleMessage::PRIORITY_HIGH``: 2
|
||||
* ``Swift_Mime_SimpleMessage::PRIORITY_NORMAL``: 3
|
||||
* ``Swift_Mime_SimpleMessage::PRIORITY_LOW``: 4
|
||||
* ``Swift_Mime_SimpleMessage::PRIORITY_LOWEST``: 5
|
||||
|
||||
::
|
||||
|
||||
// Or use the constant to be more explicit
|
||||
$message->setPriority(Swift_Mime_SimpleMessage::PRIORITY_HIGH);
|
||||
337
lib/composer/vendor/swiftmailer/swiftmailer/doc/plugins.rst
vendored
Normal file
337
lib/composer/vendor/swiftmailer/swiftmailer/doc/plugins.rst
vendored
Normal file
@@ -0,0 +1,337 @@
|
||||
Plugins
|
||||
=======
|
||||
|
||||
Plugins exist to extend, or modify the behaviour of Swift Mailer. They respond
|
||||
to Events that are fired within the Transports during sending.
|
||||
|
||||
There are a number of Plugins provided as part of the base Swift Mailer package
|
||||
and they all follow a common interface to respond to Events fired within the
|
||||
library. Interfaces are provided to "listen" to each type of Event fired and to
|
||||
act as desired when a listened-to Event occurs.
|
||||
|
||||
Although several plugins are provided with Swift Mailer out-of-the-box, the
|
||||
Events system has been specifically designed to make it easy for experienced
|
||||
object-oriented developers to write their own plugins in order to achieve
|
||||
goals that may not be possible with the base library.
|
||||
|
||||
AntiFlood Plugin
|
||||
----------------
|
||||
|
||||
Many SMTP servers have limits on the number of messages that may be sent during
|
||||
any single SMTP connection. The AntiFlood plugin provides a way to stay within
|
||||
this limit while still managing a large number of emails.
|
||||
|
||||
A typical limit for a single connection is 100 emails. If the server you
|
||||
connect to imposes such a limit, it expects you to disconnect after that number
|
||||
of emails has been sent. You could manage this manually within a loop, but the
|
||||
AntiFlood plugin provides the necessary wrapper code so that you don't need to
|
||||
worry about this logic.
|
||||
|
||||
Regardless of limits imposed by the server, it's usually a good idea to be
|
||||
conservative with the resources of the SMTP server. Sending will become
|
||||
sluggish if the server is being over-used so using the AntiFlood plugin will
|
||||
not be a bad idea even if no limits exist.
|
||||
|
||||
The AntiFlood plugin's logic is basically to disconnect and the immediately
|
||||
re-connect with the SMTP server every X number of emails sent, where X is a
|
||||
number you specify to the plugin.
|
||||
|
||||
You can also specify a time period in seconds that Swift Mailer should pause
|
||||
for between the disconnect/re-connect process. It's a good idea to pause for a
|
||||
short time (say 30 seconds every 100 emails) simply to give the SMTP server a
|
||||
chance to process its queue and recover some resources.
|
||||
|
||||
Using the AntiFlood Plugin
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The AntiFlood Plugin -- like all plugins -- is added with the Mailer class's
|
||||
``registerPlugin()`` method. It takes two constructor parameters: the number of
|
||||
emails to pause after, and optionally the number of seconds to pause for.
|
||||
|
||||
When Swift Mailer sends messages it will count the number of messages that have
|
||||
been sent since the last re-connect. Once the number hits your specified
|
||||
threshold it will disconnect and re-connect, optionally pausing for a specified
|
||||
amount of time::
|
||||
|
||||
// Create the Mailer using any Transport
|
||||
$mailer = new Swift_Mailer(
|
||||
new Swift_SmtpTransport('smtp.example.org', 25)
|
||||
);
|
||||
|
||||
// Use AntiFlood to re-connect after 100 emails
|
||||
$mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100));
|
||||
|
||||
// And specify a time in seconds to pause for (30 secs)
|
||||
$mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100, 30));
|
||||
|
||||
// Continue sending as normal
|
||||
for ($lotsOfRecipients as $recipient) {
|
||||
...
|
||||
|
||||
$mailer->send( ... );
|
||||
}
|
||||
|
||||
Throttler Plugin
|
||||
----------------
|
||||
|
||||
If your SMTP server has restrictions in place to limit the rate at which you
|
||||
send emails, then your code will need to be aware of this rate-limiting. The
|
||||
Throttler plugin makes Swift Mailer run at a rate-limited speed.
|
||||
|
||||
Many shared hosts don't open their SMTP servers as a free-for-all. Usually they
|
||||
have policies in place (probably to discourage spammers) that only allow you to
|
||||
send a fixed number of emails per-hour/day.
|
||||
|
||||
The Throttler plugin supports two modes of rate-limiting and with each, you
|
||||
will need to do that math to figure out the values you want. The plugin can
|
||||
limit based on the number of emails per minute, or the number of
|
||||
bytes-transferred per-minute.
|
||||
|
||||
Using the Throttler Plugin
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The Throttler Plugin -- like all plugins -- is added with the Mailer class'
|
||||
``registerPlugin()`` method. It has two required constructor parameters that
|
||||
tell it how to do its rate-limiting.
|
||||
|
||||
When Swift Mailer sends messages it will keep track of the rate at which
|
||||
sending messages is occurring. If it realises that sending is happening too
|
||||
fast, it will cause your program to ``sleep()`` for enough time to average out
|
||||
the rate::
|
||||
|
||||
// Create the Mailer using any Transport
|
||||
$mailer = new Swift_Mailer(
|
||||
new Swift_SmtpTransport('smtp.example.org', 25)
|
||||
);
|
||||
|
||||
// Rate limit to 100 emails per-minute
|
||||
$mailer->registerPlugin(new Swift_Plugins_ThrottlerPlugin(
|
||||
100, Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE
|
||||
));
|
||||
|
||||
// Rate limit to 10MB per-minute
|
||||
$mailer->registerPlugin(new Swift_Plugins_ThrottlerPlugin(
|
||||
1024 * 1024 * 10, Swift_Plugins_ThrottlerPlugin::BYTES_PER_MINUTE
|
||||
));
|
||||
|
||||
// Continue sending as normal
|
||||
for ($lotsOfRecipients as $recipient) {
|
||||
...
|
||||
|
||||
$mailer->send( ... );
|
||||
}
|
||||
|
||||
Logger Plugin
|
||||
-------------
|
||||
|
||||
The Logger plugins helps with debugging during the process of sending. It can
|
||||
help to identify why an SMTP server is rejecting addresses, or any other
|
||||
hard-to-find problems that may arise.
|
||||
|
||||
The Logger plugin comes in two parts. There's the plugin itself, along with one
|
||||
of a number of possible Loggers that you may choose to use. For example, the
|
||||
logger may output messages directly in realtime, or it may capture messages in
|
||||
an array.
|
||||
|
||||
One other notable feature is the way in which the Logger plugin changes
|
||||
Exception messages. If Exceptions are being thrown but the error message does
|
||||
not provide conclusive information as to the source of the problem (such as an
|
||||
ambiguous SMTP error) the Logger plugin includes the entire SMTP transcript in
|
||||
the error message so that debugging becomes a simpler task.
|
||||
|
||||
There are a few available Loggers included with Swift Mailer, but writing your
|
||||
own implementation is incredibly simple and is achieved by creating a short
|
||||
class that implements the ``Swift_Plugins_Logger`` interface.
|
||||
|
||||
* ``Swift_Plugins_Loggers_ArrayLogger``: Keeps a collection of log messages
|
||||
inside an array. The array content can be cleared or dumped out to the screen.
|
||||
|
||||
* ``Swift_Plugins_Loggers_EchoLogger``: Prints output to the screen in
|
||||
realtime. Handy for very rudimentary debug output.
|
||||
|
||||
Using the Logger Plugin
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The Logger Plugin -- like all plugins -- is added with the Mailer class'
|
||||
``registerPlugin()`` method. It accepts an instance of ``Swift_Plugins_Logger``
|
||||
in its constructor.
|
||||
|
||||
When Swift Mailer sends messages it will keep a log of all the interactions
|
||||
with the underlying Transport being used. Depending upon the Logger that has
|
||||
been used the behaviour will differ, but all implementations offer a way to get
|
||||
the contents of the log::
|
||||
|
||||
// Create the Mailer using any Transport
|
||||
$mailer = new Swift_Mailer(
|
||||
new Swift_SmtpTransport('smtp.example.org', 25)
|
||||
);
|
||||
|
||||
// To use the ArrayLogger
|
||||
$logger = new Swift_Plugins_Loggers_ArrayLogger();
|
||||
$mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));
|
||||
|
||||
// Or to use the Echo Logger
|
||||
$logger = new Swift_Plugins_Loggers_EchoLogger();
|
||||
$mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));
|
||||
|
||||
// Continue sending as normal
|
||||
for ($lotsOfRecipients as $recipient) {
|
||||
...
|
||||
|
||||
$mailer->send( ... );
|
||||
}
|
||||
|
||||
// Dump the log contents
|
||||
// NOTE: The EchoLogger dumps in realtime so dump() does nothing for it
|
||||
echo $logger->dump();
|
||||
|
||||
Decorator Plugin
|
||||
----------------
|
||||
|
||||
Often there's a need to send the same message to multiple recipients, but with
|
||||
tiny variations such as the recipient's name being used inside the message
|
||||
body. The Decorator plugin aims to provide a solution for allowing these small
|
||||
differences.
|
||||
|
||||
The decorator plugin works by intercepting the sending process of Swift Mailer,
|
||||
reading the email address in the To: field and then looking up a set of
|
||||
replacements for a template.
|
||||
|
||||
While the use of this plugin is simple, it is probably the most commonly
|
||||
misunderstood plugin due to the way in which it works. The typical mistake
|
||||
users make is to try registering the plugin multiple times (once for each
|
||||
recipient) -- inside a loop for example. This is incorrect.
|
||||
|
||||
The Decorator plugin should be registered just once, but containing the list of
|
||||
all recipients prior to sending. It will use this list of recipients to find
|
||||
the required replacements during sending.
|
||||
|
||||
Using the Decorator Plugin
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
To use the Decorator plugin, simply create an associative array of replacements
|
||||
based on email addresses and then use the mailer's ``registerPlugin()`` method
|
||||
to add the plugin.
|
||||
|
||||
First create an associative array of replacements based on the email addresses
|
||||
you'll be sending the message to.
|
||||
|
||||
.. note::
|
||||
|
||||
The replacements array becomes a 2-dimensional array whose keys are the
|
||||
email addresses and whose values are an associative array of replacements
|
||||
for that email address. The curly braces used in this example can be any
|
||||
type of syntax you choose, provided they match the placeholders in your
|
||||
email template::
|
||||
|
||||
$replacements = [];
|
||||
foreach ($users as $user) {
|
||||
$replacements[$user['email']] = [
|
||||
'{username}'=>$user['username'],
|
||||
'{resetcode}'=>$user['resetcode']
|
||||
];
|
||||
}
|
||||
|
||||
Now create an instance of the Decorator plugin using this array of replacements
|
||||
and then register it with the Mailer. Do this only once!
|
||||
|
||||
::
|
||||
|
||||
$decorator = new Swift_Plugins_DecoratorPlugin($replacements);
|
||||
|
||||
$mailer->registerPlugin($decorator);
|
||||
|
||||
When you create your message, replace elements in the body (and/or the subject
|
||||
line) with your placeholders::
|
||||
|
||||
$message = (new Swift_Message())
|
||||
->setSubject('Important notice for {username}')
|
||||
->setBody(
|
||||
"Hello {username}, you requested to reset your password.\n" .
|
||||
"Please visit https://example.com/pwreset and use the reset code {resetcode} to set a new password."
|
||||
)
|
||||
;
|
||||
|
||||
foreach ($users as $user) {
|
||||
$message->addTo($user['email']);
|
||||
}
|
||||
|
||||
When you send this message to each of your recipients listed in your
|
||||
``$replacements`` array they will receive a message customized for just
|
||||
themselves. For example, the message used above when received may appear like
|
||||
this to one user:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
Subject: Important notice for smilingsunshine2009
|
||||
|
||||
Hello smilingsunshine2009,you requested to reset your password.
|
||||
Please visit https://example.com/pwreset and use the reset code 183457 to set a new password.
|
||||
|
||||
While another use may receive the message as:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
Subject: Important notice for billy-bo-bob
|
||||
|
||||
Hello billy-bo-bob, you requested to reset your password.
|
||||
Please visit https://example.com/pwreset and use the reset code 539127 to set a new password.
|
||||
|
||||
While the decorator plugin provides a means to solve this problem, there are
|
||||
various ways you could tackle this problem without the need for a plugin. We're
|
||||
trying to come up with a better way ourselves and while we have several
|
||||
(obvious) ideas we don't quite have the perfect solution to go ahead and
|
||||
implement it. Watch this space.
|
||||
|
||||
Providing Your Own Replacements Lookup for the Decorator
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Filling an array with replacements may not be the best solution for providing
|
||||
replacement information to the decorator. If you have a more elegant algorithm
|
||||
that performs replacement lookups on-the-fly you may provide your own
|
||||
implementation.
|
||||
|
||||
Providing your own replacements lookup implementation for the Decorator is
|
||||
simply a matter of passing an instance of
|
||||
``Swift_Plugins_Decorator_Replacements`` to the decorator plugin's constructor,
|
||||
rather than passing in an array.
|
||||
|
||||
The Replacements interface is very simple to implement since it has just one
|
||||
method: ``getReplacementsFor($address)``.
|
||||
|
||||
Imagine you want to look up replacements from a database on-the-fly, you might
|
||||
provide an implementation that does this. You need to create a small class::
|
||||
|
||||
class DbReplacements implements Swift_Plugins_Decorator_Replacements {
|
||||
public function getReplacementsFor($address) {
|
||||
global $db; // Your PDO instance with a connection to your database
|
||||
$query = $db->prepare(
|
||||
"SELECT * FROM `users` WHERE `email` = ?"
|
||||
);
|
||||
|
||||
$query->execute([$address]);
|
||||
|
||||
if ($row = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
return [
|
||||
'{username}'=>$row['username'],
|
||||
'{resetcode}'=>$row['resetcode']
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Now all you need to do is pass an instance of your class into the Decorator
|
||||
plugin's constructor instead of passing an array::
|
||||
|
||||
$decorator = new Swift_Plugins_DecoratorPlugin(new DbReplacements());
|
||||
|
||||
$mailer->registerPlugin($decorator);
|
||||
|
||||
For each message sent, the plugin will call your class'
|
||||
``getReplacementsFor()`` method to find the array of replacements it needs.
|
||||
|
||||
.. note::
|
||||
|
||||
If your lookup algorithm is case sensitive, you should transform the
|
||||
``$address`` argument as appropriate -- for example by passing it through
|
||||
``strtolower()``.
|
||||
446
lib/composer/vendor/swiftmailer/swiftmailer/doc/sending.rst
vendored
Normal file
446
lib/composer/vendor/swiftmailer/swiftmailer/doc/sending.rst
vendored
Normal file
@@ -0,0 +1,446 @@
|
||||
Sending Messages
|
||||
================
|
||||
|
||||
Quick Reference for Sending a Message
|
||||
-------------------------------------
|
||||
|
||||
Sending a message is very straightforward. You create a Transport, use it to
|
||||
create the Mailer, then you use the Mailer to send the message.
|
||||
|
||||
When using ``send()`` the message will be sent just like it would be sent if
|
||||
you used your mail client. An integer is returned which includes the number of
|
||||
successful recipients. If none of the recipients could be sent to then zero
|
||||
will be returned, which equates to a boolean ``false``. If you set two ``To:``
|
||||
recipients and three ``Bcc:`` recipients in the message and all of the
|
||||
recipients are delivered to successfully then the value 5 will be returned::
|
||||
|
||||
// Create the Transport
|
||||
$transport = (new Swift_SmtpTransport('smtp.example.org', 25))
|
||||
->setUsername('your username')
|
||||
->setPassword('your password')
|
||||
;
|
||||
|
||||
/*
|
||||
You could alternatively use a different transport such as Sendmail:
|
||||
|
||||
// Sendmail
|
||||
$transport = new Swift_SendmailTransport('/usr/sbin/sendmail -bs');
|
||||
*/
|
||||
|
||||
// Create the Mailer using your created Transport
|
||||
$mailer = new Swift_Mailer($transport);
|
||||
|
||||
// Create a message
|
||||
$message = (new Swift_Message('Wonderful Subject'))
|
||||
->setFrom(['john@doe.com' => 'John Doe'])
|
||||
->setTo(['receiver@domain.org', 'other@domain.org' => 'A name'])
|
||||
->setBody('Here is the message itself')
|
||||
;
|
||||
|
||||
// Send the message
|
||||
$result = $mailer->send($message);
|
||||
|
||||
Transport Types
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Transports are the classes in Swift Mailer that are responsible for
|
||||
communicating with a service in order to deliver a Message. There are several
|
||||
types of Transport in Swift Mailer, all of which implement the
|
||||
``Swift_Transport`` interface::
|
||||
|
||||
* ``Swift_SmtpTransport``: Sends messages over SMTP; Supports Authentication;
|
||||
Supports Encryption. Very portable; Pleasingly predictable results; Provides
|
||||
good feedback;
|
||||
|
||||
* ``Swift_SendmailTransport``: Communicates with a locally installed
|
||||
``sendmail`` executable (Linux/UNIX). Quick time-to-run; Provides
|
||||
less-accurate feedback than SMTP; Requires ``sendmail`` installation;
|
||||
|
||||
* ``Swift_LoadBalancedTransport``: Cycles through a collection of the other
|
||||
Transports to manage load-reduction. Provides graceful fallback if one
|
||||
Transport fails (e.g. an SMTP server is down); Keeps the load on remote
|
||||
services down by spreading the work;
|
||||
|
||||
* ``Swift_FailoverTransport``: Works in conjunction with a collection of the
|
||||
other Transports to provide high-availability. Provides graceful fallback if
|
||||
one Transport fails (e.g. an SMTP server is down).
|
||||
|
||||
The SMTP Transport
|
||||
..................
|
||||
|
||||
The SMTP Transport sends messages over the (standardized) Simple Message
|
||||
Transfer Protocol. It can deal with encryption and authentication.
|
||||
|
||||
The SMTP Transport, ``Swift_SmtpTransport`` is without doubt the most commonly
|
||||
used Transport because it will work on 99% of web servers (I just made that
|
||||
number up, but you get the idea). All the server needs is the ability to
|
||||
connect to a remote (or even local) SMTP server on the correct port number
|
||||
(usually 25).
|
||||
|
||||
SMTP servers often require users to authenticate with a username and password
|
||||
before any mail can be sent to other domains. This is easily achieved using
|
||||
Swift Mailer with the SMTP Transport.
|
||||
|
||||
SMTP is a protocol -- in other words it's a "way" of communicating a job to be
|
||||
done (i.e. sending a message). The SMTP protocol is the fundamental basis on
|
||||
which messages are delivered all over the internet 7 days a week, 365 days a
|
||||
year. For this reason it's the most "direct" method of sending messages you can
|
||||
use and it's the one that will give you the most power and feedback (such as
|
||||
delivery failures) when using Swift Mailer.
|
||||
|
||||
Because SMTP is generally run as a remote service (i.e. you connect to it over
|
||||
the network/internet) it's extremely portable from server-to-server. You can
|
||||
easily store the SMTP server address and port number in a configuration file
|
||||
within your application and adjust the settings accordingly if the code is
|
||||
moved or if the SMTP server is changed.
|
||||
|
||||
Some SMTP servers -- Google for example -- use encryption for security reasons.
|
||||
Swift Mailer supports using both SSL and TLS encryption settings.
|
||||
|
||||
Using the SMTP Transport
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The SMTP Transport is easy to use. Most configuration options can be set with
|
||||
the constructor.
|
||||
|
||||
To use the SMTP Transport you need to know which SMTP server your code needs to
|
||||
connect to. Ask your web host if you're not sure. Lots of people ask me who to
|
||||
connect to -- I really can't answer that since it's a setting that's extremely
|
||||
specific to your hosting environment.
|
||||
|
||||
A connection to the SMTP server will be established upon the first call to
|
||||
``send()``::
|
||||
|
||||
// Create the Transport
|
||||
$transport = new Swift_SmtpTransport('smtp.example.org', 25);
|
||||
|
||||
// Create the Mailer using your created Transport
|
||||
$mailer = new Swift_Mailer($transport);
|
||||
|
||||
/*
|
||||
It's also possible to use multiple method calls
|
||||
|
||||
$transport = (new Swift_SmtpTransport())
|
||||
->setHost('smtp.example.org')
|
||||
->setPort(25)
|
||||
;
|
||||
*/
|
||||
|
||||
Encrypted SMTP
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
You can use SSL or TLS encryption with the SMTP Transport by specifying it as a
|
||||
parameter or with a method call::
|
||||
|
||||
// Create the Transport
|
||||
$transport = new Swift_SmtpTransport('smtp.example.org', 587, 'ssl');
|
||||
|
||||
// Create the Mailer using your created Transport
|
||||
$mailer = new Swift_Mailer($transport);
|
||||
|
||||
A connection to the SMTP server will be established upon the first call to
|
||||
``send()``. The connection will be initiated with the correct encryption
|
||||
settings.
|
||||
|
||||
.. note::
|
||||
|
||||
For SSL or TLS encryption to work your PHP installation must have
|
||||
appropriate OpenSSL transports wrappers. You can check if "tls" and/or
|
||||
"ssl" are present in your PHP installation by using the PHP function
|
||||
``stream_get_transports()``.
|
||||
|
||||
SMTP with a Username and Password
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Some servers require authentication. You can provide a username and password
|
||||
with ``setUsername()`` and ``setPassword()`` methods::
|
||||
|
||||
// Create the Transport the call setUsername() and setPassword()
|
||||
$transport = (new Swift_SmtpTransport('smtp.example.org', 25))
|
||||
->setUsername('username')
|
||||
->setPassword('password')
|
||||
;
|
||||
|
||||
// Create the Mailer using your created Transport
|
||||
$mailer = new Swift_Mailer($transport);
|
||||
|
||||
Your username and password will be used to authenticate upon first connect when
|
||||
``send()`` are first used on the Mailer.
|
||||
|
||||
If authentication fails, an Exception of type ``Swift_TransportException`` will
|
||||
be thrown.
|
||||
|
||||
.. note::
|
||||
|
||||
If you need to know early whether or not authentication has failed and an
|
||||
Exception is going to be thrown, call the ``start()`` method on the
|
||||
created Transport.
|
||||
|
||||
The Sendmail Transport
|
||||
......................
|
||||
|
||||
The Sendmail Transport sends messages by communicating with a locally installed
|
||||
MTA -- such as ``sendmail``.
|
||||
|
||||
The Sendmail Transport, ``Swift_SendmailTransport`` does not directly connect
|
||||
to any remote services. It is designed for Linux servers that have ``sendmail``
|
||||
installed. The Transport starts a local ``sendmail`` process and sends messages
|
||||
to it. Usually the ``sendmail`` process will respond quickly as it spools your
|
||||
messages to disk before sending them.
|
||||
|
||||
The Transport is named the Sendmail Transport for historical reasons
|
||||
(``sendmail`` was the "standard" UNIX tool for sending e-mail for years). It
|
||||
will send messages using other transfer agents such as Exim or Postfix despite
|
||||
its name, provided they have the relevant sendmail wrappers so that they can be
|
||||
started with the correct command-line flags.
|
||||
|
||||
It's a common misconception that because the Sendmail Transport returns a
|
||||
result very quickly it must therefore deliver messages to recipients quickly --
|
||||
this is not true. It's not slow by any means, but it's certainly not faster
|
||||
than SMTP when it comes to getting messages to the intended recipients. This is
|
||||
because sendmail itself sends the messages over SMTP once they have been
|
||||
quickly spooled to disk.
|
||||
|
||||
The Sendmail Transport has the potential to be just as smart of the SMTP
|
||||
Transport when it comes to notifying Swift Mailer about which recipients were
|
||||
rejected, but in reality the majority of locally installed ``sendmail``
|
||||
instances are not configured well enough to provide any useful feedback. As
|
||||
such Swift Mailer may report successful deliveries where they did in fact fail
|
||||
before they even left your server.
|
||||
|
||||
You can run the Sendmail Transport in two different modes specified by command
|
||||
line flags:
|
||||
|
||||
* "``-bs``" runs in SMTP mode so theoretically it will act like the SMTP
|
||||
Transport
|
||||
|
||||
* "``-t``" runs in piped mode with no feedback, but theoretically faster,
|
||||
though not advised
|
||||
|
||||
You can think of the Sendmail Transport as a sort of asynchronous SMTP
|
||||
Transport -- though if you have problems with delivery failures you should try
|
||||
using the SMTP Transport instead. Swift Mailer isn't doing the work here, it's
|
||||
simply passing the work to somebody else (i.e. ``sendmail``).
|
||||
|
||||
Using the Sendmail Transport
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
To use the Sendmail Transport you simply need to call ``new
|
||||
Swift_SendmailTransport()`` with the command as a parameter.
|
||||
|
||||
To use the Sendmail Transport you need to know where ``sendmail`` or another
|
||||
MTA exists on the server. Swift Mailer uses a default value of
|
||||
``/usr/sbin/sendmail``, which should work on most systems.
|
||||
|
||||
You specify the entire command as a parameter (i.e. including the command line
|
||||
flags). Swift Mailer supports operational modes of "``-bs``" (default) and
|
||||
"``-t``".
|
||||
|
||||
.. note::
|
||||
|
||||
If you run sendmail in "``-t``" mode you will get no feedback as to whether
|
||||
or not sending has succeeded. Use "``-bs``" unless you have a reason not to.
|
||||
|
||||
A sendmail process will be started upon the first call to ``send()``. If the
|
||||
process cannot be started successfully an Exception of type
|
||||
``Swift_TransportException`` will be thrown::
|
||||
|
||||
// Create the Transport
|
||||
$transport = new Swift_SendmailTransport('/usr/sbin/exim -bs');
|
||||
|
||||
// Create the Mailer using your created Transport
|
||||
$mailer = new Swift_Mailer($transport);
|
||||
|
||||
Available Methods for Sending Messages
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The Mailer class offers one method for sending Messages -- ``send()``.
|
||||
|
||||
When a message is sent in Swift Mailer, the Mailer class communicates with
|
||||
whichever Transport class you have chosen to use.
|
||||
|
||||
Each recipient in the message should either be accepted or rejected by the
|
||||
Transport. For example, if the domain name on the email address is not
|
||||
reachable the SMTP Transport may reject the address because it cannot process
|
||||
it. ``send()`` will return an integer indicating the number of accepted
|
||||
recipients.
|
||||
|
||||
.. note::
|
||||
|
||||
It's possible to find out which recipients were rejected -- we'll cover that
|
||||
later in this chapter.
|
||||
|
||||
Using the ``send()`` Method
|
||||
...........................
|
||||
|
||||
The ``send()`` method of the ``Swift_Mailer`` class sends a message using
|
||||
exactly the same logic as your Desktop mail client would use. Just pass it a
|
||||
Message and get a result.
|
||||
|
||||
The message will be sent just like it would be sent if you used your mail
|
||||
client. An integer is returned which includes the number of successful
|
||||
recipients. If none of the recipients could be sent to then zero will be
|
||||
returned, which equates to a boolean ``false``. If you set two
|
||||
``To:`` recipients and three ``Bcc:`` recipients in the message and all of the
|
||||
recipients are delivered to successfully then the value 5 will be returned::
|
||||
|
||||
// Create the Transport
|
||||
$transport = new Swift_SmtpTransport('localhost', 25);
|
||||
|
||||
// Create the Mailer using your created Transport
|
||||
$mailer = new Swift_Mailer($transport);
|
||||
|
||||
// Create a message
|
||||
$message = (new Swift_Message('Wonderful Subject'))
|
||||
->setFrom(['john@doe.com' => 'John Doe'])
|
||||
->setTo(['receiver@domain.org', 'other@domain.org' => 'A name'])
|
||||
->setBody('Here is the message itself')
|
||||
;
|
||||
|
||||
// Send the message
|
||||
$numSent = $mailer->send($message);
|
||||
|
||||
printf("Sent %d messages\n", $numSent);
|
||||
|
||||
/* Note that often that only the boolean equivalent of the
|
||||
return value is of concern (zero indicates FALSE)
|
||||
|
||||
if ($mailer->send($message))
|
||||
{
|
||||
echo "Sent\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Failed\n";
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
Sending Emails in Batch
|
||||
.......................
|
||||
|
||||
If you want to send a separate message to each recipient so that only their own
|
||||
address shows up in the ``To:`` field, follow the following recipe:
|
||||
|
||||
* Create a Transport from one of the provided Transports --
|
||||
``Swift_SmtpTransport``, ``Swift_SendmailTransport``,
|
||||
or one of the aggregate Transports.
|
||||
|
||||
* Create an instance of the ``Swift_Mailer`` class, using the Transport as
|
||||
it's constructor parameter.
|
||||
|
||||
* Create a Message.
|
||||
|
||||
* Iterate over the recipients and send message via the ``send()`` method on
|
||||
the Mailer object.
|
||||
|
||||
Each recipient of the messages receives a different copy with only their own
|
||||
email address on the ``To:`` field.
|
||||
|
||||
Make sure to add only valid email addresses as recipients. If you try to add an
|
||||
invalid email address with ``setTo()``, ``setCc()`` or ``setBcc()``, Swift
|
||||
Mailer will throw a ``Swift_RfcComplianceException``.
|
||||
|
||||
If you add recipients automatically based on a data source that may contain
|
||||
invalid email addresses, you can prevent possible exceptions by validating the
|
||||
addresses using ``Swift_Validate::email($email)`` and only adding addresses
|
||||
that validate. Another way would be to wrap your ``setTo()``, ``setCc()`` and
|
||||
``setBcc()`` calls in a try-catch block and handle the
|
||||
``Swift_RfcComplianceException`` in the catch block.
|
||||
|
||||
Handling invalid addresses properly is especially important when sending emails
|
||||
in large batches since a single invalid address might cause an unhandled
|
||||
exception and stop the execution or your script early.
|
||||
|
||||
.. note::
|
||||
|
||||
In the following example, two emails are sent. One to each of
|
||||
``receiver@domain.org`` and ``other@domain.org``. These recipients will
|
||||
not be aware of each other::
|
||||
|
||||
// Create the Transport
|
||||
$transport = new Swift_SmtpTransport('localhost', 25);
|
||||
|
||||
// Create the Mailer using your created Transport
|
||||
$mailer = new Swift_Mailer($transport);
|
||||
|
||||
// Create a message
|
||||
$message = (new Swift_Message('Wonderful Subject'))
|
||||
->setFrom(['john@doe.com' => 'John Doe'])
|
||||
->setBody('Here is the message itself')
|
||||
;
|
||||
|
||||
// Send the message
|
||||
$failedRecipients = [];
|
||||
$numSent = 0;
|
||||
$to = ['receiver@domain.org', 'other@domain.org' => 'A name'];
|
||||
|
||||
foreach ($to as $address => $name)
|
||||
{
|
||||
if (is_int($address)) {
|
||||
$message->setTo($name);
|
||||
} else {
|
||||
$message->setTo([$address => $name]);
|
||||
}
|
||||
|
||||
$numSent += $mailer->send($message, $failedRecipients);
|
||||
}
|
||||
|
||||
printf("Sent %d messages\n", $numSent);
|
||||
|
||||
Finding out Rejected Addresses
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
It's possible to get a list of addresses that were rejected by the Transport by
|
||||
using a by-reference parameter to ``send()``.
|
||||
|
||||
As Swift Mailer attempts to send the message to each address given to it, if a
|
||||
recipient is rejected it will be added to the array. You can pass an existing
|
||||
array, otherwise one will be created by-reference.
|
||||
|
||||
Collecting the list of recipients that were rejected can be useful in
|
||||
circumstances where you need to "prune" a mailing list for example when some
|
||||
addresses cannot be delivered to.
|
||||
|
||||
Getting Failures By-reference
|
||||
.............................
|
||||
|
||||
Collecting delivery failures by-reference with the ``send()`` method is as
|
||||
simple as passing a variable name to the method call::
|
||||
|
||||
$mailer = new Swift_Mailer( ... );
|
||||
|
||||
$message = (new Swift_Message( ... ))
|
||||
->setFrom( ... )
|
||||
->setTo([
|
||||
'receiver@bad-domain.org' => 'Receiver Name',
|
||||
'other@domain.org' => 'A name',
|
||||
'other-receiver@bad-domain.org' => 'Other Name'
|
||||
))
|
||||
->setBody( ... )
|
||||
;
|
||||
|
||||
// Pass a variable name to the send() method
|
||||
if (!$mailer->send($message, $failures))
|
||||
{
|
||||
echo "Failures:";
|
||||
print_r($failures);
|
||||
}
|
||||
|
||||
/*
|
||||
Failures:
|
||||
Array (
|
||||
0 => receiver@bad-domain.org,
|
||||
1 => other-receiver@bad-domain.org
|
||||
)
|
||||
*/
|
||||
|
||||
If the Transport rejects any of the recipients, the culprit addresses will be
|
||||
added to the array provided by-reference.
|
||||
|
||||
.. note::
|
||||
|
||||
If the variable name does not yet exist, it will be initialized as an
|
||||
empty array and then failures will be added to that array. If the variable
|
||||
already exists it will be type-cast to an array and failures will be added
|
||||
to it.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user