mirror of
https://github.com/openvk/chandler.git
synced 2025-01-22 15:24:15 +03:00
Add Postmark support as an alternative to SMTP mailing
This commit is contained in:
parent
10b2ae82d8
commit
1e45ef5ef7
3 changed files with 996 additions and 237 deletions
|
@ -3,22 +3,43 @@ namespace Chandler\Email;
|
||||||
use Swift_SmtpTransport;
|
use Swift_SmtpTransport;
|
||||||
use Swift_Message;
|
use Swift_Message;
|
||||||
use Swift_Mailer;
|
use Swift_Mailer;
|
||||||
|
use Postmark\PostmarkClient;
|
||||||
|
|
||||||
class Email
|
class Email
|
||||||
{
|
{
|
||||||
static function send(string $to, string $subject, string $html)
|
static function send(string $to, string $subject, string $html)
|
||||||
{
|
{
|
||||||
$transport = new Swift_SmtpTransport(CHANDLER_ROOT_CONF["email"]["host"], CHANDLER_ROOT_CONF["email"]["port"], "ssl");
|
if(isset(CHANDLER_ROOT_CONF["email"]["postmark"])) {
|
||||||
$transport->setUsername(CHANDLER_ROOT_CONF["email"]["addr"]);
|
return (new PostmarkClient(CHANDLER_ROOT_CONF["email"]["postmark"]["key"]))->sendEmail(
|
||||||
$transport->setPassword(CHANDLER_ROOT_CONF["email"]["pass"]);
|
CHANDLER_ROOT_CONF["email"]["postmark"]["user"],
|
||||||
|
$to,
|
||||||
$message = new Swift_Message($subject);
|
$subject,
|
||||||
$message->getHeaders()->addTextHeader("Sensitivity", "Company-Confidential");
|
$html,
|
||||||
$message->setFrom(CHANDLER_ROOT_CONF["email"]["addr"]);
|
strip_tags($html),
|
||||||
$message->setTo($to);
|
NULL,
|
||||||
$message->setBody($html, "text/html");
|
true,
|
||||||
|
NULL,
|
||||||
$mailer = new Swift_Mailer($transport);
|
NULL,
|
||||||
return $mailer->send($message);
|
NULL,
|
||||||
|
["Sensitivity" => "Company-Confidential"],
|
||||||
|
NULL,
|
||||||
|
"None",
|
||||||
|
NULL,
|
||||||
|
CHANDLER_ROOT_CONF["email"]["postmark"]["stream"]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$transport = new Swift_SmtpTransport(CHANDLER_ROOT_CONF["email"]["host"], CHANDLER_ROOT_CONF["email"]["port"], "ssl");
|
||||||
|
$transport->setUsername(CHANDLER_ROOT_CONF["email"]["addr"]);
|
||||||
|
$transport->setPassword(CHANDLER_ROOT_CONF["email"]["pass"]);
|
||||||
|
|
||||||
|
$message = new Swift_Message($subject);
|
||||||
|
$message->getHeaders()->addTextHeader("Sensitivity", "Company-Confidential");
|
||||||
|
$message->setFrom(CHANDLER_ROOT_CONF["email"]["addr"]);
|
||||||
|
$message->setTo($to);
|
||||||
|
$message->setBody($html, "text/html");
|
||||||
|
|
||||||
|
$mailer = new Swift_Mailer($transport);
|
||||||
|
return $mailer->send($message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,11 @@
|
||||||
"nette/safe-stream": "^2.4",
|
"nette/safe-stream": "^2.4",
|
||||||
"nette/tokenizer": "^3.1",
|
"nette/tokenizer": "^3.1",
|
||||||
"firebase/php-jwt": "^5.0",
|
"firebase/php-jwt": "^5.0",
|
||||||
"tracy/tracy": "^2.7",
|
|
||||||
"symfony/translation": "^5.0",
|
"symfony/translation": "^5.0",
|
||||||
"symfony/yaml": "^5.3"
|
"symfony/yaml": "^5.3",
|
||||||
|
"guzzlehttp/guzzle": "^6.0",
|
||||||
|
"wildbit/postmark-php": "^4.0",
|
||||||
|
"tracy/tracy": "2.9"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-yaml": "for faster yaml parsing"
|
"ext-yaml": "for faster yaml parsing"
|
||||||
|
|
1180
composer.lock
generated
1180
composer.lock
generated
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue