Skip to content

Commit

Permalink
Fix various mailing issues
Browse files Browse the repository at this point in the history
- Increase frequency of scheduler
- Fix non-ASCII mail sender names
- Avoid duplicate Reply-To headers
  • Loading branch information
daniel-lerch committed Aug 28, 2020
1 parent 195854d commit 5729e01
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion install/default/docker/kool-scheduler
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*/5 * * * * www-data /usr/local/bin/php /var/www/html/scheduler.php
*/1 * * * * www-data /usr/local/bin/php /var/www/html/scheduler.php
19 changes: 11 additions & 8 deletions mailing.php
Original file line number Diff line number Diff line change
Expand Up @@ -1118,11 +1118,11 @@ function ko_mailing_store_moderation($imap, $mail, $login, $modifyRcpts = true,
$header = preg_replace('/(\n|^)X-Spam-Report:(.*)(\n\s+(.*))*\n/i', '$1', $header);
$header = preg_replace('/(\n|^)DKIM-Signature:(.*)(\n\s+(.*))*\n/i', '$1', $header);

$manualReplyTo = FALSE;
$replyTo = '';
// Delete any existing Reply-To headers to avoid duplicates
$header = preg_replace('/(\n|^)Reply-To:(.*)(\n\s+(.*))*\n/i', '$1', $header);

$replyTo = NULL;
if($mail['_reply_to']) {
//Remove Reply-To
$header = preg_replace('/(\n|^)Reply-To:(.*)(\n\s+(.*))*\n/i', '$1', $header);
//Set new Reply-To
switch($mail['_reply_to']) {
case 'list':
Expand All @@ -1134,22 +1134,25 @@ function ko_mailing_store_moderation($imap, $mail, $login, $modifyRcpts = true,
break;
}
$header = trim($header)."\nReply-To: ".$replyTo."\n";
$manualReplyTo = TRUE;
}


//Set from address to an spf save sender address
$header = preg_replace('/(\n|^)From:(.*)(\n\s+(.*))*\n/i', '$1', $header);

if(!$manualReplyTo) {
if($replyTo === NULL) {
$header = trim($header)."\nReply-To: ".$mail['from']."\n";
}

$mailFrom = $mail['from'];
ko_mail_get_spf_from($mailFrom, $replyTo, $mailSender, $login['id']);

$fromEmail = array_key_first($mailFrom);
$from = '"'.str_replace('"', '', $mailFrom[$fromEmail]).'" <'.$fromEmail.'>';
if (empty($mailFrom[$fromEmail])) {
$from = $fromEmail;
} else {
// Computed From fields might contain no ASCII chars and have to be encoded first
$from = mb_encode_mimeheader($mailFrom[$fromEmail], 'UTF-8', 'Q').' <'.$fromEmail.'>';
}
$header = trim($header)."\nFrom: ".$from."\n";

if($mailSender) {
Expand Down

0 comments on commit 5729e01

Please sign in to comment.