Truncated MailFrom address - Incorrect Windows detection

Created on 3 July 2018, over 6 years ago
Updated 5 July 2023, over 1 year ago

The "from" email address of messages sent by Drupal (contact form, password reset, etc..) is trimmed of 5 characters on the left when running Drupal on Windows Server 2008 R2 with IIS 7.5 and PHP 7.1 64-bit (FastCGI).

"contact@domain.ext" is changed to "ct@domain.ext", and "info@domain.ext" becomes "domain.ext"

The problem has happened after upgrading PHP from 5.x to 7.1. PHP is run via FastCGI, and PHP 7.1 is installed in 64-bit version. 5.x versions were only available in 32-bit.

PHP mail() function works a bit differently on Windows and Drupal mail function (in system.mail.inc) includes a workaround :

if (!isset($_SERVER['WINDIR']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Win32') === FALSE) {
  // default processing
}
else {
  // Windows processing - set and reset sendmail_from
}

I think that this workaround is rarely used, since $_SERVER['SERVER_SOFTWARE'] value is "Microsoft-IIS/x.y" x and y being major and minor version of IIS, on Windows servers running IIS, and not Win32

If I change Windows detection code to use PHP_OS, messages sent by Drupal are OK, with complete "from" address.

if (!isset($_SERVER['WINDIR']) && strpos(strtolower(substr(PHP_OS, 0, 3)), 'win') === FALSE) {
  // default processing
}
else {
  // Windows processing - set and reset sendmail_from
}
🐛 Bug report
Status

Active

Version

7.0 ⚰️

Component
Mail 

Last updated 5 days ago

No maintainer
Created by

🇫🇷France flebas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024