Solved

Email notification CC issue - Version 20.10 - using php file template.

  • 12 January 2023
  • 4 replies
  • 125 views

Badge +5

Hi Everyone,

First time asking question here. We’re using a php template for email notification. and the issue is when if two or more CC recipient were added on host and service URL. We got a double qoutes “” on the cc part of the notification so its not sending to correct receipient. the php file is from https://github.com/mcinquin/centreon-notifications we just modify it. its working on Centreon 2.8.17 but its not working on Centreon 21.10.7. We just separate the emails by a comma on host and service URL.

 

 

Hope someone has an idea about my issue. 

icon

Best answer by kimpoy0730 21 June 2024, 02:05

View original

4 replies

Userlevel 5
Badge +14

hello

you are using a 7 years old php script you have modified, could you please check the syntax of the php you changed is still working with the current php version you use on your new centreon 21? (there has been some major change in php since centreon 2 and centreon 21, like php5 to 7 or 8)

 

the original script don’t use “CC”, only “TO” , so the part you modified is probably the root of your problem and without the code you modified it’s not easy to debug

(I know I had some array manipulation issues between php versions, there are warnings on the output console when you run in shell the script)

 

(try debugging the script and add output on your server, copy it, add some console prints and check if you have warnings and comment the send mail at the end, you can run it manually without all the informations for debugging, just run it with fake value)

Badge +5

@christophe.niel-ACT 

Thanks for the response, I already figured it out and it working fine now. 

 

 

 

Userlevel 5
Badge +11

Hi @kimpoy0730, feel free to share the solution with the whole community, so that those who may have the same problem can also benefit from it : ) Thanks in advance

Badge +5

Before 

$f_serviceurlb =str_replace("+","",$f_serviceurla);
$f_serviceurlc =str_replace("%40","@",$f_serviceurlb);
$f_serviceurld =str_replace("%2526","&",$f_serviceurlc);
$str_explode=explode("%2C",$f_serviceurld);
$servicecc1 = $str_explode[0];
$servicecc2 = $str_explode[1];
$servicecc3 = $str_explode[2];
$servicecc4 = $str_explode[3];
$servicecc5 = $str_explode[4];

$f_hosturlb =str_replace("+","",$f_hosturla);
$f_hosturlc =str_replace("%40","@",$f_hosturlb);
$f_hosturld =str_replace("%2526","&",$f_hosturlc);
$str_explode=explode("%2C",$f_hosturld);
$hostcc1 = $str_explode[0];
$hostcc2 = $str_explode[1];
$hostcc3 = $str_explode[2];
$hostcc4 = $str_explode[3];
$hostcc5 = $str_explode[4];


After

$f_serviceurlb =str_replace("+","",$f_serviceurla);
$f_serviceurlc =str_replace("%40","@",$f_serviceurlb);
$f_serviceurld =str_replace("%2526","&",$f_serviceurlc);
$str_explode=explode(", ",$f_serviceurld);
$servicecc1 = $str_explode[0];
$servicecc2 = $str_explode[1];
$servicecc3 = $str_explode[2];
$servicecc4 = $str_explode[3];
$servicecc5 = $str_explode[4];

$f_hosturlb =str_replace("+","",$f_hosturla);
$f_hosturlc =str_replace("%40","@",$f_hosturlb);
$f_hosturld =str_replace("%2526","&",$f_hosturlc);
$str_explode=explode(", ",$f_hosturld);
$hostcc1 = $str_explode[0];
$hostcc2 = $str_explode[1];
$hostcc3 = $str_explode[2];
$hostcc4 = $str_explode[3];
$hostcc5 = $str_explode[4];

We just changed the $str_explode=explode part from “%2C” to  “, “ to fix the issue.

Reply