smtp is in
This commit is contained in:
parent
14b9c76f64
commit
96ed7021db
|
@ -3,7 +3,7 @@ require_once "vendor/autoload.php";
|
|||
require_once "activethreads.php";
|
||||
require_once "email.php";
|
||||
define("MYBB_ROOT", "../");
|
||||
define("MYBB_PREFIX", "mybb_");
|
||||
define("MYBB_PREFIX", "mybbfo_");
|
||||
define("FORUM_ID", 0);// 0 means all forums
|
||||
$dsn = 'mysql:host=localhost;dbname=mybb;charset=utf8';
|
||||
$usr = 'root';
|
||||
|
@ -31,14 +31,12 @@ foreach ($tmp as $row) {
|
|||
unset($tmp);
|
||||
$transport = Swift_SmtpTransport::newInstance($smtp['smtp_host'], $smtp['smtp_port'])
|
||||
->setUsername($smtp['smtp_user'])
|
||||
->setPassword($smtp['smtp_password']);
|
||||
->setPassword($smtp['smtp_pass']);
|
||||
$mailer = Swift_Mailer::newInstance($transport);
|
||||
|
||||
foreach ($users as $user) {
|
||||
$email = $user['email'];
|
||||
ob_start();
|
||||
print_email($user['username'], $url.'/unsubscribe', $threads);
|
||||
$message = ob_end_flush();
|
||||
$message = print_email($user['username'], $url.'/unsubscribe', $threads);
|
||||
$message = Swift_Message::newInstance()
|
||||
->setSubject('Daily digest')
|
||||
->setFrom(array('john@doe.com' => 'John Doe'))
|
||||
|
|
37
email.php
37
email.php
|
@ -1,5 +1,6 @@
|
|||
<?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">
|
||||
<html>
|
||||
<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>
|
||||
</head>
|
||||
<body>
|
||||
<p><?php echo $username ?>,</p>
|
||||
<p>$username,</p>
|
||||
|
||||
<p>Here’s 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>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($threads as $thread) { ?>
|
||||
END;
|
||||
foreach ($threads as $thread) {
|
||||
$message .= '
|
||||
<tr>
|
||||
<td style="padding: 0.5em"><?php echo $thread['forumname'] ?></td>
|
||||
<td style="padding: 0.5em"><?php echo $thread['subject'] ?></td>
|
||||
<td style="padding: 0.5em">
|
||||
<?php echo $thread['username'] ?>,
|
||||
<?php echo date('d.m.Y H:m:i', $thread['dateline']) ?>
|
||||
<td style="padding: 0.5em">'.$thread['forumname'].'</td>
|
||||
<td style="padding: 0.5em">'.$thread['subject'].'</td>
|
||||
<td style="padding: 0.5em">'.
|
||||
$thread['username'].', '.
|
||||
date('d.m.Y H:m:i', $thread['dateline']).'
|
||||
</td>
|
||||
<td style="padding: 0.5em"><?php echo $thread['replies'] ?></td>
|
||||
<td style="padding: 0.5em">
|
||||
<?php echo $thread['lastposter'] ?>,
|
||||
<?php echo date('d.m.Y H:m:i', $thread['lastpost']) ?>
|
||||
<td style="padding: 0.5em">'.$thread['replies'].'</td>
|
||||
<td style="padding: 0.5em">'.
|
||||
$thread['lastposter'].', '.
|
||||
date('d.m.Y H:m:i', $thread['lastpost']).'
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
';
|
||||
}
|
||||
$message .= <<<END
|
||||
</tbody>
|
||||
</table></p>
|
||||
|
||||
<p>Thank you,<br>
|
||||
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>
|
||||
</html>
|
||||
<?php } ?>
|
||||
END;
|
||||
return $message;
|
||||
} ?>
|
||||
|
|
Reference in a new issue