I need to send an email with Nickname as first preference, if that not present then use Contact name. Cant figure out what token to use?

I have tried this but seems not rendering correctly in email:

{capture assign=nickname}{contact.nick_name}{/capture} 
Dear {if $nickname}{contact.nick_name}{else}{contact.sort_name}{/if}


{capture assign=nickname}Tota{/capture} Dear {if $nickname}Tota{else}Mr. Tapash Datta{/if}

can anyone help please? Thanks

1 Answer 1


You will need to turn on CIVICRM_MAIL_SMARTY in civicrm.settings.php to use smarty templating for conditional and more complex logic.

enter image description here



  • 1
    I seem to receive thousands of smarty error in drupal every time the email is viewed after enabling this option!! how can I fix it please? thanks
    – Tapash
    May 25, 2019 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.