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_Message;
|
||||
use Swift_Mailer;
|
||||
use Postmark\PostmarkClient;
|
||||
|
||||
class Email
|
||||
{
|
||||
static function send(string $to, string $subject, string $html)
|
||||
{
|
||||
$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"]);
|
||||
if(isset(CHANDLER_ROOT_CONF["email"]["postmark"])) {
|
||||
return (new PostmarkClient(CHANDLER_ROOT_CONF["email"]["postmark"]["key"]))->sendEmail(
|
||||
CHANDLER_ROOT_CONF["email"]["postmark"]["user"],
|
||||
$to,
|
||||
$subject,
|
||||
$html,
|
||||
strip_tags($html),
|
||||
NULL,
|
||||
true,
|
||||
NULL,
|
||||
NULL,
|
||||
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");
|
||||
$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);
|
||||
$mailer = new Swift_Mailer($transport);
|
||||
return $mailer->send($message);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,9 +10,11 @@
|
|||
"nette/safe-stream": "^2.4",
|
||||
"nette/tokenizer": "^3.1",
|
||||
"firebase/php-jwt": "^5.0",
|
||||
"tracy/tracy": "^2.7",
|
||||
"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": {
|
||||
"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