smtp is in

This commit is contained in:
Alexander Yakovlev 2017-05-04 16:16:16 +07:00
parent 14b9c76f64
commit 96ed7021db
3 changed files with 26 additions and 20 deletions

View file

@ -3,7 +3,7 @@ require_once "vendor/autoload.php";
require_once "activethreads.php"; require_once "activethreads.php";
require_once "email.php"; require_once "email.php";
define("MYBB_ROOT", "../"); define("MYBB_ROOT", "../");
define("MYBB_PREFIX", "mybb_"); define("MYBB_PREFIX", "mybbfo_");
define("FORUM_ID", 0);// 0 means all forums define("FORUM_ID", 0);// 0 means all forums
$dsn = 'mysql:host=localhost;dbname=mybb;charset=utf8'; $dsn = 'mysql:host=localhost;dbname=mybb;charset=utf8';
$usr = 'root'; $usr = 'root';
@ -31,14 +31,12 @@ foreach ($tmp as $row) {
unset($tmp); unset($tmp);
$transport = Swift_SmtpTransport::newInstance($smtp['smtp_host'], $smtp['smtp_port']) $transport = Swift_SmtpTransport::newInstance($smtp['smtp_host'], $smtp['smtp_port'])
->setUsername($smtp['smtp_user']) ->setUsername($smtp['smtp_user'])
->setPassword($smtp['smtp_password']); ->setPassword($smtp['smtp_pass']);
$mailer = Swift_Mailer::newInstance($transport); $mailer = Swift_Mailer::newInstance($transport);
foreach ($users as $user) { foreach ($users as $user) {
$email = $user['email']; $email = $user['email'];
ob_start(); $message = print_email($user['username'], $url.'/unsubscribe', $threads);
print_email($user['username'], $url.'/unsubscribe', $threads);
$message = ob_end_flush();
$message = Swift_Message::newInstance() $message = Swift_Message::newInstance()
->setSubject('Daily digest') ->setSubject('Daily digest')
->setFrom(array('john@doe.com' => 'John Doe')) ->setFrom(array('john@doe.com' => 'John Doe'))

View file

@ -1,5 +1,6 @@
<?php <?php
function print_email($username, $unsubscription, $threads) { ?> function print_email($username, $unsubscription, $threads) {
$message = <<<END
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html> <html>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta http-equiv="content-type" content="text/html; charset=UTF-8">
@ -7,7 +8,7 @@ function print_email($username, $unsubscription, $threads) { ?>
<title>Daily digest from Olympic Business Forum</title> <title>Daily digest from Olympic Business Forum</title>
</head> </head>
<body> <body>
<p><?php echo $username ?>,</p> <p>$username,</p>
<p>Heres a daily update of activity on the Olympic Business forum.</p> <p>Heres a daily update of activity on the Olympic Business forum.</p>
@ -20,28 +21,34 @@ function print_email($username, $unsubscription, $threads) { ?>
<th style="padding: 0.5em">Last update</th> <th style="padding: 0.5em">Last update</th>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($threads as $thread) { ?> END;
foreach ($threads as $thread) {
$message .= '
<tr> <tr>
<td style="padding: 0.5em"><?php echo $thread['forumname'] ?></td> <td style="padding: 0.5em">'.$thread['forumname'].'</td>
<td style="padding: 0.5em"><?php echo $thread['subject'] ?></td> <td style="padding: 0.5em">'.$thread['subject'].'</td>
<td style="padding: 0.5em"> <td style="padding: 0.5em">'.
<?php echo $thread['username'] ?>, $thread['username'].', '.
<?php echo date('d.m.Y H:m:i', $thread['dateline']) ?> date('d.m.Y H:m:i', $thread['dateline']).'
</td> </td>
<td style="padding: 0.5em"><?php echo $thread['replies'] ?></td> <td style="padding: 0.5em">'.$thread['replies'].'</td>
<td style="padding: 0.5em"> <td style="padding: 0.5em">'.
<?php echo $thread['lastposter'] ?>, $thread['lastposter'].', '.
<?php echo date('d.m.Y H:m:i', $thread['lastpost']) ?> date('d.m.Y H:m:i', $thread['lastpost']).'
</td> </td>
</tr> </tr>
<?php } ?> ';
}
$message .= <<<END
</tbody> </tbody>
</table></p> </table></p>
<p>Thank you,<br> <p>Thank you,<br>
Olympic Business Forum Staff</p> Olympic Business Forum Staff</p>
<p>To unsubscribe from these daily digests, click here: <a href="<?php echo $unsubscription ?>"><?php echo $unsubscription ?></a></p> <p>To unsubscribe from these daily digests, click here: <a href="$unsubscription">$unsubscription</a></p>
</body> </body>
</html> </html>
<?php } ?> END;
return $message;
} ?>

1
patch.sql Normal file
View file

@ -0,0 +1 @@
ALTER TABLE mybb_users ADD COLUMN isSubscribed TinyInt( 1 ) NOT NULL DEFAULT '1';