Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions oit.module
Original file line number Diff line number Diff line change
Expand Up @@ -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 <oitsrvcom@colorado.edu>';
$message['from'] = 'oitsrvcom@colorado.edu';
$message['headers']['From'] = $from;
Comment on lines +638 to +640
$message['headers']['Sender'] = 'oitsrvcom@colorado.edu';
$message['headers']['Return-Path'] = 'oitsrvcom@colorado.edu';
Comment on lines +641 to +642
if (empty($message['headers']['Reply-To'])) {
$message['headers']['Reply-To'] = 'oithelp@colorado.edu';
}
Comment on lines +637 to +645
}
Loading