diff --git a/.tests/test-mu-plugin/plugin.php b/.tests/test-mu-plugin/plugin.php index 665dcec..4c501ea 100644 --- a/.tests/test-mu-plugin/plugin.php +++ b/.tests/test-mu-plugin/plugin.php @@ -161,4 +161,36 @@ // print_r( $test ); // echo ''; // exit(); -// } ); \ No newline at end of file +// } ); + +/** + * Email: AWS SES Messaging - with headers. + */ +// add_action( 'init', function () { +// $test = \Souptik\AIOMessaging\Email\send( +// [ 'dev2@souptik.dev' ], +// 'Yay its working!', +// 'This is some long mail body.', +// '', +// 'dev1@souptik.dev', // Use verified email address for the AWS credential you are using. +// [ +// 'reply_to_name' => 'Reply Test', +// 'reply_to_email' => 'dev2@souptik.dev', +// 'cc' => [ +// [ +// 'name' => 'CC Test', +// 'email' => 'cc@souptik.dev', +// ], +// ], +// 'attachments' => [ +// 'SameFileDifferentName.php' => trailingslashit( WP_CONTENT_DIR ) . '/mu-plugins/test-all-in-one-messaging.php', +// ], +// ], +// 'aws_ses' +// ); +// echo '

Email: AWS SES Messaging -- Triggered from `test-mu-plugin`

'; +// echo '
';
+// 	print_r( $test );
+// 	echo '
'; +// exit(); +// } ); diff --git a/composer.json b/composer.json index 8abb5d2..c4966dd 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,8 @@ "name": "souptik/all-in-one-messaging", "description": "Limitless Communication: All-in-One, super scalable, messaging Solution for WordPress.", "require": { - "utopia-php/messaging": "^0.10.0" + "utopia-php/messaging": "^0.10.0", + "aws/aws-sdk-php": "^3.324" }, "require-dev": { "roots/wordpress": "6.6.2", diff --git a/composer.lock b/composer.lock index 6bd016d..c0c169f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,551 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a597fbf65fb5a4edc3fb4dd235acb710", + "content-hash": "3e3482fb3d782d224b99ca023cce6880", "packages": [ + { + "name": "aws/aws-crt-php", + "version": "v1.2.6", + "source": { + "type": "git", + "url": "https://github.com/awslabs/aws-crt-php.git", + "reference": "a63485b65b6b3367039306496d49737cf1995408" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/awslabs/aws-crt-php/zipball/a63485b65b6b3367039306496d49737cf1995408", + "reference": "a63485b65b6b3367039306496d49737cf1995408", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35||^5.6.3||^9.5", + "yoast/phpunit-polyfills": "^1.0" + }, + "suggest": { + "ext-awscrt": "Make sure you install awscrt native extension to use any of the functionality." + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "AWS SDK Common Runtime Team", + "email": "aws-sdk-common-runtime@amazon.com" + } + ], + "description": "AWS Common Runtime for PHP", + "homepage": "https://github.com/awslabs/aws-crt-php", + "keywords": [ + "amazon", + "aws", + "crt", + "sdk" + ], + "support": { + "issues": "https://github.com/awslabs/aws-crt-php/issues", + "source": "https://github.com/awslabs/aws-crt-php/tree/v1.2.6" + }, + "time": "2024-06-13T17:21:28+00:00" + }, + { + "name": "aws/aws-sdk-php", + "version": "3.324.1", + "source": { + "type": "git", + "url": "https://github.com/aws/aws-sdk-php.git", + "reference": "5b824a9b8015a38f18c53b023975c0f63c7bd3dc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/5b824a9b8015a38f18c53b023975c0f63c7bd3dc", + "reference": "5b824a9b8015a38f18c53b023975c0f63c7bd3dc", + "shasum": "" + }, + "require": { + "aws/aws-crt-php": "^1.2.3", + "ext-json": "*", + "ext-pcre": "*", + "ext-simplexml": "*", + "guzzlehttp/guzzle": "^6.5.8 || ^7.4.5", + "guzzlehttp/promises": "^1.4.0 || ^2.0", + "guzzlehttp/psr7": "^1.9.1 || ^2.4.5", + "mtdowling/jmespath.php": "^2.6", + "php": ">=7.2.5", + "psr/http-message": "^1.0 || ^2.0" + }, + "require-dev": { + "andrewsville/php-token-reflection": "^1.4", + "aws/aws-php-sns-message-validator": "~1.0", + "behat/behat": "~3.0", + "composer/composer": "^1.10.22", + "dms/phpunit-arraysubset-asserts": "^0.4.0", + "doctrine/cache": "~1.4", + "ext-dom": "*", + "ext-openssl": "*", + "ext-pcntl": "*", + "ext-sockets": "*", + "nette/neon": "^2.3", + "paragonie/random_compat": ">= 2", + "phpunit/phpunit": "^5.6.3 || ^8.5 || ^9.5", + "psr/cache": "^1.0", + "psr/simple-cache": "^1.0", + "sebastian/comparator": "^1.2.3 || ^4.0", + "yoast/phpunit-polyfills": "^1.0" + }, + "suggest": { + "aws/aws-php-sns-message-validator": "To validate incoming SNS notifications", + "doctrine/cache": "To use the DoctrineCacheAdapter", + "ext-curl": "To send requests using cURL", + "ext-openssl": "Allows working with CloudFront private distributions and verifying received SNS messages", + "ext-sockets": "To use client-side monitoring" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Aws\\": "src/" + }, + "exclude-from-classmap": [ + "src/data/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Amazon Web Services", + "homepage": "http://aws.amazon.com" + } + ], + "description": "AWS SDK for PHP - Use Amazon Web Services in your PHP project", + "homepage": "http://aws.amazon.com/sdkforphp", + "keywords": [ + "amazon", + "aws", + "cloud", + "dynamodb", + "ec2", + "glacier", + "s3", + "sdk" + ], + "support": { + "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", + "issues": "https://github.com/aws/aws-sdk-php/issues", + "source": "https://github.com/aws/aws-sdk-php/tree/3.324.1" + }, + "time": "2024-10-11T18:22:01+00:00" + }, + { + "name": "guzzlehttp/guzzle", + "version": "7.9.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "d281ed313b989f213357e3be1a179f02196ac99b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d281ed313b989f213357e3be1a179f02196ac99b", + "reference": "d281ed313b989f213357e3be1a179f02196ac99b", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.5.3 || ^2.0.3", + "guzzlehttp/psr7": "^2.7.0", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "ext-curl": "*", + "guzzle/client-integration-tests": "3.0.2", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.39 || ^9.6.20", + "psr/log": "^1.1 || ^2.0 || ^3.0" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.9.2" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "time": "2024-07-24T11:22:20+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8", + "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2024-07-18T10:29:17+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "2.7.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/a70f5c95fb43bc83f07c9c948baa0dc1829bf201", + "reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "0.9.0", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.7.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2024-07-18T11:15:46+00:00" + }, + { + "name": "mtdowling/jmespath.php", + "version": "2.8.0", + "source": { + "type": "git", + "url": "https://github.com/jmespath/jmespath.php.git", + "reference": "a2a865e05d5f420b50cc2f85bb78d565db12a6bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/a2a865e05d5f420b50cc2f85bb78d565db12a6bc", + "reference": "a2a865e05d5f420b50cc2f85bb78d565db12a6bc", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "symfony/polyfill-mbstring": "^1.17" + }, + "require-dev": { + "composer/xdebug-handler": "^3.0.3", + "phpunit/phpunit": "^8.5.33" + }, + "bin": [ + "bin/jp.php" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "files": [ + "src/JmesPath.php" + ], + "psr-4": { + "JmesPath\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Declaratively specify how to extract elements from a JSON document", + "keywords": [ + "json", + "jsonpath" + ], + "support": { + "issues": "https://github.com/jmespath/jmespath.php/issues", + "source": "https://github.com/jmespath/jmespath.php/tree/2.8.0" + }, + "time": "2024-09-04T18:46:31+00:00" + }, { "name": "phpmailer/phpmailer", "version": "v6.9.1", @@ -87,6 +630,357 @@ ], "time": "2023-11-25T22:23:28+00:00" }, + { + "name": "psr/http-client", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client" + }, + "time": "2023-09-23T14:17:50+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory" + }, + "time": "2024-04-15T12:06:14+00:00" + }, + { + "name": "psr/http-message", + "version": "2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/2.0" + }, + "time": "2023-04-04T09:54:51+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.5.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:32:20+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, { "name": "utopia-php/messaging", "version": "0.10.0", diff --git a/inc/email/adapters/aws-ses/class-adapter.php b/inc/email/adapters/aws-ses/class-adapter.php new file mode 100644 index 0000000..d5a7c22 --- /dev/null +++ b/inc/email/adapters/aws-ses/class-adapter.php @@ -0,0 +1,84 @@ +get_settings(); + + // Return early if in-valid settings. + if ( empty( $settings['region'] ) || empty( $settings['key'] ) || empty( $settings['secret'] ) ) { + return null; + } + + // Return the adapter. + return new AWS_SES( $settings['region'], $settings['key'], $settings['secret'] ); + } + + /** + * Get adapter settings. + * + * @return array{ + * region: string, + * key: string, + * secret: string, + * } + */ + public function get_settings(): array { + // Return the adapter settings. + return [ + 'region' => strval( get_option( EMAIL_SLUG . '_' . SLUG . '_region', '' ) ), + 'key' => strval( get_option( EMAIL_SLUG . '_' . SLUG . '_key', '' ) ), + 'secret' => strval( get_option( EMAIL_SLUG . '_' . SLUG . '_secret', '' ) ), + ]; + } + + /** + * Get settings fields. + * + * @return array + */ + public static function get_settings_fields(): array { + // Return the settings fields. + return [ + EMAIL_SLUG . '_' . SLUG . '_region' => [ + 'label' => __( 'Region', 'all-in-one-messaging' ), + 'type' => 'text', + 'sanitize_callback' => 'sanitize_text_field', + ], + EMAIL_SLUG . '_' . SLUG . '_key' => [ + 'label' => __( 'Key', 'all-in-one-messaging' ), + 'type' => 'text', + 'sanitize_callback' => 'sanitize_text_field', + ], + EMAIL_SLUG . '_' . SLUG . '_secret' => [ + 'label' => __( 'Secret', 'all-in-one-messaging' ), + 'type' => 'password', + 'sanitize_callback' => 'sanitize_text_field', + ], + ]; + } +} diff --git a/inc/email/adapters/aws-ses/class-aws-ses.php b/inc/email/adapters/aws-ses/class-aws-ses.php new file mode 100644 index 0000000..2924e2a --- /dev/null +++ b/inc/email/adapters/aws-ses/class-aws-ses.php @@ -0,0 +1,211 @@ +region ) || empty( $this->key ) || empty( $this->secret ) ) { + return; + } + + // Initialize the SES Client. + $this->client = new SesClient( + [ + 'version' => 'latest', + 'region' => $this->region, + 'credentials' => [ + 'key' => $this->key, + 'secret' => $this->secret, + ], + ] + ); + } + + /** + * Get adapter name. + * + * @return string + */ + public function getName(): string { + // Return the name. + return static::NAME; + } + + /** + * Get adapter description. + * + * @return int + */ + public function getMaxMessagesPerRequest(): int { + // Return the maximum messages per request. + return 1000; + } + + /** + * Core function to send the email. + * + * @param ?EmailMessage $message Email message object. + * + * @throws Exception If the message is invalid. + * + * @return mixed[] + */ + protected function process( EmailMessage $message = null ): array { + // Return early if message is invalid. + if ( ! $message instanceof EmailMessage ) { + throw new Exception( 'Invalid message' ); + } + + // Return early if SES client is not initialized. + if ( ! $this->client instanceof SesClient ) { + throw new Exception( 'SES Client not initialized' ); + } + + // Create a new response. + $response = new Response( $this->getType() ); + + // Get the reply to email. + $reply_to = ! empty( $message->getReplyToEmail() ) ? $message->getReplyToEmail() : $message->getFromEmail(); + + // Initialize the mail. + $mail = new PHPMailer(); + + // Add recipients. + foreach ( $message->getTo() as $recipient ) { + $mail->addAddress( $recipient, $recipient ); + } + + // Build the mail. + $mail->setFrom( $message->getFromEmail(), $message->getFromName() ); + $mail->addReplyTo( $reply_to, $reply_to ); + $mail->Subject = $message->getSubject(); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- PHPMailer's naming convention. + $mail->isHTML( $message->isHtml() ); + $mail->Body = $message->isHtml() ? $message->getContent() : ''; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- PHPMailer's naming convention. + $mail->AltBody = $message->isHtml() ? '' : $message->getContent(); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- PHPMailer's naming convention. + + // Add CC. + if ( is_array( $message->getCC() ) ) { + foreach ( $message->getCC() as $cc ) { + $mail->addAddress( $cc['email'] ?? '', $cc['name'] ?? '' ); + } + } + + // Add BCC. + if ( is_array( $message->getBCC() ) ) { + foreach ( $message->getBCC() as $bcc ) { + $mail->addBCC( $bcc['email'] ?? '', $bcc['name'] ?? '' ); + } + } + + // Start building the attachments. + if ( ! empty( $message->getAttachments() ) ) { + $size = 0; + + // Get the total size of all the attachments. + foreach ( $message->getAttachments() as $attachment ) { + // Skip if attachment not valid. + if ( ! $attachment instanceof Attachment ) { + continue; + } + + // Add up the sizes. + $size += filesize( $attachment->getPath() ); + } + + // Throw error if the size exceeds the maximum allowed size. + if ( $size > self::MAX_ATTACHMENT_BYTES ) { + throw new Exception( 'Attachments size exceeds the maximum allowed size of ' ); + } + + // Loop over the attachments. + foreach ( $message->getAttachments() as $attachment ) { + // Skip if attachment not valid. + if ( ! $attachment instanceof Attachment ) { + continue; + } + + // Add the attachment. + $mail->addAttachment( $attachment->getPath() ); + } + } + + // Attempt to assemble the above components into a MIME message. + if ( ! $mail->preSend() ) { + throw new Exception( 'Could not assemble mail.' ); + } else { + // Create a new variable that contains the MIME message. + $mail_payload = $mail->getSentMIMEMessage(); + } + + // Send the email. + try { + $this->client->sendRawEmail( + [ + 'RawMessage' => [ + 'Data' => $mail_payload, + ], + ] + ); + + // Set the response. + $response->setDeliveredTo( count( $message->getTo() ) ); + + // Build the response. + foreach ( $message->getTo() as $to ) { + $response->addResult( $to ); + } + } catch ( SesException $e ) { + // Build the response. + foreach ( $message->getTo() as $to ) { + if ( ! empty( $e->getAwsErrorMessage() ) ) { + $response->addResult( $to, $e->getAwsErrorMessage() ); + } else { + $response->addResult( $to, 'Unknown error' ); + } + } + } + + // Return the response. + return $response->toArray(); + } +} diff --git a/inc/email/adapters/aws-ses/namespace.php b/inc/email/adapters/aws-ses/namespace.php new file mode 100644 index 0000000..961a69f --- /dev/null +++ b/inc/email/adapters/aws-ses/namespace.php @@ -0,0 +1,38 @@ + __( 'AWS SES', 'all-in-one-messaging' ), + 'adapter' => new Adapter(), + 'options' => Adapter::get_settings_fields(), + ]; + + // Return the adapters. + return $adapters; + } + ); +} diff --git a/inc/email/namespace.php b/inc/email/namespace.php index 86dced6..0473906 100644 --- a/inc/email/namespace.php +++ b/inc/email/namespace.php @@ -17,6 +17,7 @@ // Load different email adapters. require_once SD_AIO_MESSAGING_PATH . '/inc/email/adapters/mailgun/namespace.php'; require_once SD_AIO_MESSAGING_PATH . '/inc/email/adapters/brevo/namespace.php'; +require_once SD_AIO_MESSAGING_PATH . '/inc/email/adapters/aws-ses/namespace.php'; // Sub-module to hijack `wp_mail` function. require_once SD_AIO_MESSAGING_PATH . '/inc/email/wp-mail/namespace.php'; @@ -48,7 +49,7 @@ function autoload( string $class_name = '' ): void { // Add the namespace. if ( false !== $last_ns_pos ) { - $namespace = substr( $class_name, 0, $last_ns_pos ); + $namespace = str_replace( '_', '-', substr( $class_name, 0, $last_ns_pos ) ); $class_name = substr( $class_name, $last_ns_pos + 1 ); $file = str_replace( '\\', DIRECTORY_SEPARATOR, $namespace ) . DIRECTORY_SEPARATOR; }