[ZBX-22812] DNS error with Office 365 relay notification Created: 2023 May 17  Updated: 2025 May 12

Status: Open
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 6.4.2
Fix Version/s: None

Type: Patch request Priority: Trivial
Reporter: Rodrigo Camarao Assignee: Victor Breda Credidio
Resolution: Unresolved Votes: 1
Labels: actions, patch
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Zabbix 6.4 on Ubuntu 22.04


Attachments: PNG File Capture.PNG     File ControllerMediatypeCreate.php.patch     File ControllerMediatypeUpdate.php.patch    

 Description   

Steps to reproduce:

  1. Setup "Alert" "Media types" with "Office365 Relay"
  2. Configure "Email" with any domain @domain.com.br (TLD that are not just .com)
  3. Update configuration and MX/SMTP Server get misspelled.

Result:
SMTP server: "example.com-br.mail.protection.outlook.com"

Log entry

failed to send email: Couldn't resolve host name: Could not resolve host:  domain.com-br.mail.protection.outlook.com

Expected:

SMTP server: "domain-com-br.mail.protection.outlook.com"

There's a "." (dot) after domain when should be "-" (hyphen)

 domain-com-br.mail.protection.outlook.com

 

Fix: (WARNING)

I didn't spent a lot of time checking the code. I'm not a programmer, this change is not the best solution!!  But I was able to identify the error.

 

zabbix/app/controllers/CControllerMediatypeUpdate.php => line 122

zabbix/app/controllers/CControllerMediatypeUpdate.php => line 132

 

$formatted_domain = substr_replace($domain, '-', strrpos($domain, '.'), 1);

Changed to:

$formatted_domain = str_replace('.', '-', $domain);



 Comments   
Comment by Rodrigo Camarao [ 2023 May 17 ]

A note that in order to work correctly, it's still necessary to configure a relay/connector in Exchange Online (Office 365). This issue is  just about Office 365 mail server FQDN generation.

Comment by IITG Zabbix [ 2025 May 12 ]

This is still an issue in Zabbix 7.2. The changes need to be made to both app/controllers/CControllerMediatypeUpdate.php and app/controllers/CControllerMediatypeCreate.php

I'd recommend making sure the domain is properly formatted e.g.

$formatted_domain = strtolower(str_replace('.', '-', trim($domain)));
Comment by IITG Zabbix [ 2025 May 12 ]

Patch files are attached.

ControllerMediatypeUpdate.php.patch

ControllerMediatypeCreate.php.patch

Generated at Wed Jul 16 09:35:33 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.