I have come up with a bit of a work around, but I still feel that this would make an amazing extension.
I am using the Syndication extension to get the 5 top post. https://FLARUMSITE.com/atom/discussions?sort=top
. Then I am using the Mailing extension to send a pasted HTML email to my members.
I used the below php script to generate the html email and just paste it in. I have mine saved as newsletter.php and behind a password protected folder. I like the idea of seeing the visual results before sending the email, especially since the Mailing extension does not have a preview.
Find and Replace FLARUMSITE
to make it easier to adjust to your own.
<?php
function fetchFeed($url) {
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_USERAGENT => 'FLARUMSITEBot/1.0',
CURLOPT_SSL_VERIFYPEER => false,
]);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$feedData = fetchFeed('https://FLARUMSITE.com/atom/discussions?sort=top');
if (!$feedData) {
die('<h2>Error: Could not fetch feed.</h2>');
}
$xml = simplexml_load_string($feedData);
if (!$xml) {
die('<h2>Error: Failed to parse XML.</h2>');
}
ob_start();
?>
<!-- BEGIN FLARUMSITE Weekly Email Digest -->
<table cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px; margin: auto; font-family: Arial, sans-serif; color: #333;">
<tr>
<td align="center" style="padding: 20px;">
<img src="https://FLARUMSITE.com/assets/logo-6m4unrdr.png" alt="FLARUMSITE Logo" width="200" style="margin-bottom: 20px;">
<h2 style="color: #007bff; margin: 0;">📰 FLARUMSITE Weekly Digest</h2>
<p style="font-size: 16px;">Here's a roundup of hot topics and discussions happening on FLARUMSITE.com this week:</p>
</td>
</tr>
<?php
$count = 0;
foreach ($xml->entry as $entry):
if (++$count > 5) break;
$title = htmlspecialchars((string)$entry->title);
$link = (string)$entry->link['href'];
$summary = strip_tags((string)$entry->summary);
$summaryShort = strlen($summary) > 200 ? substr($summary, 0, 200) . '…' : $summary;
?>
<tr>
<td style="padding: 10px 20px;">
<h3 style="margin-bottom: 5px;"><a href="<?= $link ?>" style="color: #007bff; text-decoration: none;"><?= $title ?></a></h3>
<p style="margin-top: 0; font-size: 14px; line-height: 1.5;"><?= $summaryShort ?></p>
</td>
</tr>
<?php endforeach; ?>
<tr>
<td align="center" style="padding: 20px; font-size: 14px; color: #777;">
<hr style="border: none; border-top: 1px solid #ddd; margin: 20px 0;">
<p>Want more? Visit <a href="https://FLARUMSITE.com" style="color: #007bff;">FLARUMSITE.com</a> to join the conversation.</p>
</td>
</tr>
</table>
<!-- END FLARUMSITE Weekly Email Digest -->
<?php
$htmlOutput = ob_get_clean();
echo $htmlOutput;
?>
<!-- Show a copy-paste box -->
<div style="max-width: 600px; margin: 40px auto;">
<h3>📋 Copy & Paste Email HTML</h3>
<textarea style="width: 100%; height: 300px; font-family: monospace; font-size: 14px; padding: 10px; border: 1px solid #ccc;">
<?= htmlspecialchars($htmlOutput); ?>
</textarea>
</div>
Here is the final look of the page: