It seems, that official SugarCRM docs don't provide any information about using if/else conditions in email templates. I didn't believed them, so i dug into SugarCRM code.
Research:
Sending e-mail is done in EmailMan class in method sendEmail:
$template_data = $this->current_emailtemplate
->parse_email_template(
array(
'subject' => $this->current_emailtemplate->subject,
'body_html' => $this->current_emailtemplate->body_html,
'body' => $this->current_emailtemplate->body,
)
, $focus_name, $module
, $macro_nv);
It uses parse_email_template method from class EmailTemplate. It's not so well-written, as i was thinking. And it's only providing basic variable replacing. Let's look at it a little closer:
function parse_email_template($template_text_array, $focus_name, $focus, &$macro_nv)
{
[...] //variable initiation
//preparing prefixes to search for variables (all variables are in "$some_name" format
$pattern_prefix = '$' . strtolower($beanList[$focus_name]) . '_';
$pattern_prefix_length = strlen($pattern_prefix);
$pattern = '/\\' . $pattern_prefix . '[A-Za-z_0-9]*/';
foreach ($template_text_array as $key => $template_text) {
[...] //searching for variables matching $pattern and replacing them with proper values
$return_array[$key] = $template_text;
}
return $return_array;
}
Conclusion:
What i can say more - SugarCRM at this point doesn't provide any conditions nor smarty or other template engine. You can try to modify their code to implement it, but i wouldn't recommend that as it is a litlle spaghetti ;)