From c60c09033b21d29417c0eb57bcaa728314af1a5e Mon Sep 17 00:00:00 2001 From: protitude Date: Mon, 13 Jul 2026 14:24:18 -0400 Subject: [PATCH] smtp to symfony lite update --- oit.module | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/oit.module b/oit.module index ff4f197..43a347d 100644 --- a/oit.module +++ b/oit.module @@ -620,3 +620,27 @@ function oit_block_access(Block $block, $operation, AccountInterface $account) { } } } + +/** + * Implements hook_mail_alter(). + * + * Forces the From address on every outgoing message to the OIT service account + * (oitsrvcom@colorado.edu). Office 365 rejects mail whose From does not match + * an authorized sender (SendAsDenied), so this reproduces the From-rewriting + * the drupal/smtp module performed before the migration to Symfony Mailer Lite. + * Symfony Mailer Lite has no transport-level From override, so the header is + * forced here, after hook_mail() has run and before the message is sent. + * + * Reply-To defaults to oithelp@colorado.edu so replies still reach the help + * desk, but any Reply-To a module set explicitly is preserved. + */ +function oit_mail_alter(&$message) { + $from = 'Office of Information Technology '; + $message['from'] = 'oitsrvcom@colorado.edu'; + $message['headers']['From'] = $from; + $message['headers']['Sender'] = 'oitsrvcom@colorado.edu'; + $message['headers']['Return-Path'] = 'oitsrvcom@colorado.edu'; + if (empty($message['headers']['Reply-To'])) { + $message['headers']['Reply-To'] = 'oithelp@colorado.edu'; + } +}