diff options
| author | David T. Sadler <davidtsadler@googlemail.com> | 2021-07-07 16:01:17 +0100 |
|---|---|---|
| committer | David T. Sadler <davidtsadler@googlemail.com> | 2021-07-07 16:01:17 +0100 |
| commit | 7b21a6654ef973639ec1fcd7958403448c1caa87 (patch) | |
| tree | 945d187cfaee014c84f3b3810b25e53b049e3a8f | |
| parent | 7656c1f90cd8ef2bc6f5bd3d26a583128dd749c7 (diff) | |
Refactor email script
| -rw-r--r-- | scripts/email_bookmarks.php | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/scripts/email_bookmarks.php b/scripts/email_bookmarks.php index 891ab4d..8162488 100644 --- a/scripts/email_bookmarks.php +++ b/scripts/email_bookmarks.php @@ -6,8 +6,6 @@ $config = require_once(__DIR__.'/../config.php'); $urls = file($config['path_to_file'], FILE_IGNORE_NEW_LINES); -$urls = array_reverse($urls); - $urls = array_slice($urls, 0, 5); if (!count($urls)) { @@ -16,15 +14,16 @@ if (!count($urls)) { $email = $config['email']; -$message = buildMessage($urls, $config['site']); - -$headers = implode("\r\n", [ - "From: {$email['from']}", - 'MIME-Version: 1.0', - 'Content-Type: text/html; charset=UTF-8', -]); - -mail($email['to'], $email['subject'], $message, $headers); +mail( + $email['to'], + $email['subject'], + buildMessage($urls, $config['site']), + [ + 'From' => $email['from'], + 'MIME-Version' => '1.0', + 'Content-Type' => 'text/html; charset=UTF-8', + ] +); function buildMessage(array $urls, string $site): string { |
