SMTP mailing
This commit is contained in:
parent
911aec0531
commit
14b9c76f64
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"minimum-stability": "dev",
|
||||
"require": {
|
||||
"swiftmailer/swiftmailer": "^5.4"
|
||||
}
|
||||
}
|
||||
|
|
73
composer.lock
generated
Normal file
73
composer.lock
generated
Normal file
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "49673bcd5268eaad7d3ebb1abf627a5b",
|
||||
"content-hash": "8bfc43134a045ff6c4df3097bc1ea9fb",
|
||||
"packages": [
|
||||
{
|
||||
"name": "swiftmailer/swiftmailer",
|
||||
"version": "5.x-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/swiftmailer/swiftmailer.git",
|
||||
"reference": "cd4ffa87f4902527b1725587d368062c28eb98c2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/cd4ffa87f4902527b1725587d368062c28eb98c2",
|
||||
"reference": "cd4ffa87f4902527b1725587d368062c28eb98c2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9.1",
|
||||
"symfony/phpunit-bridge": "~3.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.4-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.org",
|
||||
"keywords": [
|
||||
"email",
|
||||
"mail",
|
||||
"mailer"
|
||||
],
|
||||
"time": "2017-05-01 15:54:38"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": []
|
||||
}
|
28
digest.php
28
digest.php
|
@ -16,7 +16,33 @@ WHERE usergroup = 4
|
|||
AND isSubscribed = 1");
|
||||
$users->execute();
|
||||
$users = $users->fetchAll();
|
||||
|
||||
$url = $pdo->prepare("SELECT value FROM ".MYBB_PREFIX."settings WHERE name = 'bburl'");
|
||||
$url->execute();
|
||||
$url = $url->fetch()['value'];
|
||||
|
||||
$tmp = $pdo->prepare("SELECT name, value FROM ".MYBB_PREFIX."settings WHERE name LIKE 'smtp_%'");
|
||||
$tmp->execute();
|
||||
$tmp = $tmp->fetchAll();
|
||||
$smtp = [];
|
||||
foreach ($tmp as $row) {
|
||||
$smtp[$row['name']] = $row['value'];
|
||||
}
|
||||
unset($tmp);
|
||||
$transport = Swift_SmtpTransport::newInstance($smtp['smtp_host'], $smtp['smtp_port'])
|
||||
->setUsername($smtp['smtp_user'])
|
||||
->setPassword($smtp['smtp_password']);
|
||||
$mailer = Swift_Mailer::newInstance($transport);
|
||||
|
||||
foreach ($users as $user) {
|
||||
$email = $user['email'];
|
||||
print_email($user['username'], '/unsubscribe', $threads);
|
||||
ob_start();
|
||||
print_email($user['username'], $url.'/unsubscribe', $threads);
|
||||
$message = ob_end_flush();
|
||||
$message = Swift_Message::newInstance()
|
||||
->setSubject('Daily digest')
|
||||
->setFrom(array('john@doe.com' => 'John Doe'))
|
||||
->setTo(array($email => $user['username']))
|
||||
->setBody($message, 'text/html');
|
||||
$mailer->send($message);
|
||||
}
|
||||
|
|
Reference in a new issue